From b73d429551c29e1b894136477447bc7cece228ea Mon Sep 17 00:00:00 2001 From: William Ghelfi Date: Sun, 21 Jun 2015 13:05:58 +0200 Subject: [PATCH] use original line-height instead of original font-size for line-height preservation --- demo/styles/main.css | 3 ++- demo/styles/main.scss | 1 + src/ng-FitText.js | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/demo/styles/main.css b/demo/styles/main.css index 1eb0c07..d656ee2 100644 --- a/demo/styles/main.css +++ b/demo/styles/main.css @@ -121,7 +121,8 @@ body { font-size: 50px; text-align: center; margin-top: 10px; - margin-bottom: 10px; } + margin-bottom: 10px; + line-height: 1.5; } #plh-container p { text-transform: uppercase; } diff --git a/demo/styles/main.scss b/demo/styles/main.scss index 33372e4..4492f26 100644 --- a/demo/styles/main.scss +++ b/demo/styles/main.scss @@ -174,6 +174,7 @@ body { text-align: center; margin-top: 10px; margin-bottom: 10px; + line-height: 1.5; } p { diff --git a/src/ng-FitText.js b/src/ng-FitText.js index ce02042..97cba89 100644 --- a/src/ng-FitText.js +++ b/src/ng-FitText.js @@ -40,7 +40,7 @@ var minFontSize = attrs.fittextMin || config.min || Number.NEGATIVE_INFINITY; var maxFontSize = attrs.fittextMax || config.max || Number.POSITIVE_INFINITY; var preserveLineHeight = attrs.fittextPreserveLineHeight !== undefined ? attrs.fittextPreserveLineHeight : config.preserveLineHeight; - var originalFontSize = window.getComputedStyle(element[0],null).getPropertyValue('font-size'); + var originalLineHeight = window.getComputedStyle(element[0],null).getPropertyValue('line-height'); var resizer = function() { element[0].style.lineHeight = '1'; @@ -53,7 +53,7 @@ parseFloat(minFontSize) ) + 'px'; if ( preserveLineHeight !== undefined ) { - element[0].style.lineHeight = originalFontSize; + element[0].style.lineHeight = originalLineHeight; } };