patrickmarabeas / ng-FitText.js

An AngularJS directive for inflating web type.
http://patrickmarabeas.github.io/ng-FitText.js
MIT License
222 stars 61 forks source link

Optionally preserve original line-height #29

Closed trumbitta closed 9 years ago

trumbitta commented 9 years ago

I'm using ngFitText in a context where I have several text elements aligned. They have different lenghts, meaning they all resize differently.

Given ngFitText sets line-height: 1, they also lose the alignment.

A data-fittext-preserve-line-height="true" option, setting the line-height to the value of the original font-size, would be very handy :)

I tried myself something around this line of code:

window.getComputedStyle(element[0],null).getPropertyValue("font-size");

But I just couldn't make it properly work inside the algorithm you are using.

trumbitta commented 9 years ago

Hey, I may have found a simple and elegant-enough solution! Just let me polish it a bit, then I'll close this and submit a pull-request :smiley_cat: