Skip to content

Commit

Permalink
Updating the resizer function to support min and max sizes instead of…
Browse files Browse the repository at this point in the history
… paying attention to the original font size.
  • Loading branch information
adactio committed Feb 29, 2012
1 parent c7742af commit c6275ea
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions fittext.js
Expand Up @@ -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.
Expand Down

0 comments on commit c6275ea

Please sign in to comment.