Skip to content

Commit

Permalink
Fix to issue with original font size limit when expanding viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderreiff committed Jul 2, 2014
1 parent 243771b commit 750b323
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions jquery.scalem.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
referenceWidthOffset: 0 /* Sets the width to subtract from reference element's width for calculating new CSS values */,
doNotExceedOriginal: false /* Limits the maximum value of the font size to the original value */
}, oOptions),
updateStyles = function(o, e) {
updateStyles = function(o, e, origFontSize) {
var $o = $(o),
/* Create clone to get true text width */
origFontSize = parseInt($o.css('font-size').replace('px','')),
$o2 = $o.clone().css({
'width': 'auto',
'display': 'none',
Expand Down Expand Up @@ -55,7 +54,6 @@
break;
}
}
console.log(newFontSize, origFontSize);
if (oSettings.doNotExceedOriginal) {
newFontSize = Math.min(newFontSize, origFontSize);
}
Expand All @@ -75,13 +73,14 @@
};
return this.each(function() {
// This scope required for resize handler
var o = this;
var o = this,
origFontSize = parseInt($(o).css('font-size').replace('px',''));
// Update CSS styles upon resize
$(window).resize(function(e) {
updateStyles(o, e);
updateStyles(o, e, origFontSize);
});
// Set font size on load
updateStyles(o);
updateStyles(o, null, origFontSize);
});
};
}(jQuery));

0 comments on commit 750b323

Please sign in to comment.