Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

… paying attention to the original font size.
  • Loading branch information...
commit c6275ea51a90e07300856129b18ad0cc5e676fc3 1 parent c7742af
@adactio authored
Showing with 7 additions and 3 deletions.
  1. +7 −3 fittext.js
View
10 fittext.js
@@ -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.
Please sign in to comment.
Something went wrong with that request. Please try again.