From aee418452005834e59d267021d1e6e5802041cdf Mon Sep 17 00:00:00 2001 From: Zarko Hristovski Date: Thu, 24 Sep 2015 15:02:34 +0200 Subject: [PATCH] Prevent invalid ratio calculation and fitting --- src/ng-FitText.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ng-FitText.js b/src/ng-FitText.js index e5cc8a3..70f19b1 100644 --- a/src/ng-FitText.js +++ b/src/ng-FitText.js @@ -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(