Skip to content

Commit

Permalink
Prevent invalid ratio calculation and fitting
Browse files Browse the repository at this point in the history
  • Loading branch information
zarko-tg committed Sep 24, 2015
1 parent 6d60c52 commit aee4184
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/ng-FitText.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
var maxFontSize = attrs.fittextMax || config.max || Number.POSITIVE_INFINITY;

var resizer = function() {
if ( element[0].offsetHeight * element[0].offsetWidth === 0 ) {
// Skip setting the font size if the element height or width
// have been set to 0 (or auto) for any reason.
return;
}

element[0].style.fontSize = '10px';
var ratio = element[0].offsetHeight / element[0].offsetWidth / nl;
element[0].style.fontSize = Math.max(
Expand Down

0 comments on commit aee4184

Please sign in to comment.