clampify icon indicating copy to clipboard operation
clampify copied to clipboard

Option to disable for browsers that support line-clamp

Open warudin opened this issue 5 years ago • 2 comments

From all much-used browsers, currently only Firefox doesn't support line-clamp. Would it be possible to add an option to disable clampify when the browser supports line-clamp?

warudin avatar Mar 18 '19 16:03 warudin

Hello, I don't have time to maintanance this plugin, I wrote it for own needs, and upload to github, in case it could be helpful to someone else. You can make a PR with this feature. I think it shouldn't be hard.

artem328 avatar Mar 18 '19 16:03 artem328

I'm not really familiar with your code so I don't know how to implement it, but something like the code below worked for me.

Lines 2-4 with the CSS.supports-check is what's important. Support for line-clamp is being checked through the CSS API and if there's support the function is cancelled.

function clampifyText() {
	if (CSS.supports("(line-clamp: 1)") || CSS.supports("(-webkit-line-clamp: 1)")) {
		return;
	}

	jQuery('.clamp').each(function() {
		var clamp = 2;

		if (jQuery(this).data('clamp') !== 'undefined') {
			clamp = jQuery(this).data('clamp');
		}

		jQuery(this).clampify({
			maxLines: clamp,
			autoUpdate: true,
		});
	});
}

warudin avatar Mar 18 '19 17:03 warudin