Skip to content

Instantly share code, notes, and snippets.

@reubeningber
Created October 20, 2014 18:33
Show Gist options
  • Select an option

  • Save reubeningber/167cce302d2d14600a49 to your computer and use it in GitHub Desktop.

Select an option

Save reubeningber/167cce302d2d14600a49 to your computer and use it in GitHub Desktop.
FitText Helper
// FitText
// Add class js-fit-text & Set the following data-attributes: data-fit-compressor="<compressor value>" data-fit-max-font-size=<size>px" data-fit-min-font-size="<size>px"
$('.js-fit-text').each(function() {
var $this = $(this),
fitCompressor = $this.data('fit-compressor') || 1,
fitMaxFontSize = $this.data('fit-max-font-size') || Number.POSITIVE_INFINITY,
fitMinFontSize = $this.data('fit-min-font-size') || Number.NEGATIVE_INFINITY;
$this.fitText(fitCompressor, {maxFontSize: fitMaxFontSize, minFontSize: fitMinFontSize});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment