Skip to content

Instantly share code, notes, and snippets.

@raynimmo
Created October 11, 2014 16:46
Show Gist options
  • Save raynimmo/6c85acf28f2c9a747764 to your computer and use it in GitHub Desktop.
Save raynimmo/6c85acf28f2c9a747764 to your computer and use it in GitHub Desktop.
initialise fittext.js
(function($) {
// fittext.js plugin
$.fn.fitText = function(kompressor, options){
var compressor = kompressor || 1,
settings = $.extend({
'minFontSize' : Number.NEGATIVE_INFINITY,
'maxFontSize' : Number.POSITIVE_INFINITY
}, options);
return this.each(function(){
var $this = $(this);
var resizer = function () {
$this.css('font-size', Math.max(Math.min($this.width() / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)));
};
resizer();
$(window).on('resize orientationchange', resizer);
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment