Created
October 11, 2014 16:46
-
-
Save raynimmo/6c85acf28f2c9a747764 to your computer and use it in GitHub Desktop.
initialise fittext.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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