Skip to content

Commit

Permalink
Merge pull request #36 from zarko-tg/prevent_invalid_ratio_calculatio…
Browse files Browse the repository at this point in the history
…n_and_fitting

Prevent invalid ratio calculation and fitting
  • Loading branch information
patrickmarabeas committed Jan 17, 2016
2 parents 6d60c52 + aee4184 commit 7de9c5b
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 7de9c5b

Please sign in to comment.