Permalink
Browse files

Updating the resizer function to support min and max sizes instead of…

… paying attention to the original font size.
  • Loading branch information...
adactio committed Feb 29, 2012
1 parent c7742af commit c6275ea51a90e07300856129b18ad0cc5e676fc3
Showing with 7 additions and 3 deletions.
  1. +7 −3 fittext.js
View
@@ -22,12 +22,16 @@
window.fitText = function (el, kompressor) {
+ var settings = {
+ 'minFontSize' : Number.NEGATIVE_INFINITY,
+ 'maxFontSize' : Number.POSITIVE_INFINITY
+ };
+
var fit = function (el) {
- var origFontSize = parseFloat( css(el, 'font-size') ),
- compressor = kompressor || 1;
+ var compressor = kompressor || 1;
var resizer = function () {
- el.style.fontSize = Math.min(el.clientWidth / (compressor * 10), origFontSize) + 'px';
+ el.style.fontSize = Math.max(Math.min(el.clientWidth / (compressor*10), parseFloat(settings.maxFontSize)), parseFloat(settings.minFontSize)) + 'px';
};
// Call once to set.

0 comments on commit c6275ea

Please sign in to comment.