STRML / textFit

A jQuery-free component that quickly fits single and multi-line text to the width (and optionally height) of its container.
https://textfit.strml.net
642 stars 122 forks source link

Line-height and timing issues. #63

Open SamTheDev85 opened 2 years ago

SamTheDev85 commented 2 years ago

I found that line-height can break the script if the line-height is larger than the element size. To work around this (I need to adjust the line height to get the font to center), I set the line-height style to normal then call the script and clear the normal setting after completion.

I am getting inconsistent results on the first execution of a fresh browser window. The same element on first calculation of a fresh browser instance will result in 32px but in later calculations, the correct result of 35px is achieved. I thought this would be because the function does not return fast enough so I tried wrapping it into a promise. Does the script have callbacks perhaps onComplete?

STRML commented 2 years ago

It's synchronous, so no callback is necessary.

SamTheDev85 commented 2 years ago

Can you think of anything that might be causing the disparity?