malte-wessel / react-textfit

React component to fit headlines and paragraphs into elements
http://malte-wessel.github.io/react-textfit/
MIT License
474 stars 144 forks source link

Often "Freezes" at minimum size #39

Open brandonkal opened 6 years ago

brandonkal commented 6 years ago

I use this with a Gatsby site. Often the font size will initially load at the minimum font size and it does not update.

sis-dk commented 5 years ago

Did you find a fix?

brandonkal commented 5 years ago

No I did not. I ended up implementing a component like this using CSS calc().

However, it is not perfect with SSR as the text will be streamed at minimum size in the HTML and stay that way until react hydrates.

42x42x42 commented 5 years ago

Try to use a parameter 'throttle' i.e 1000 milliseconds, it should calculate height with delay when text, styles, etc already fully loaded.

ceiphr commented 3 years ago

Same issue. @brandonkal would you be willing to share your CSS solution?

koraysels commented 3 years ago

same problem using nextjs. IU tried loading it dynamically but still it won't work.

brandonkal commented 3 years ago

@ceiphr No longer using calc for other reasons but the idea is to figure out what size you want the text at different breakpoints and build an algebraic function to achieve that initial sizing as a function of view width.

ceiphr commented 3 years ago

@ceiphr No longer using calc for other reasons but the idea is to figure out what size you want the text at different breakpoints and build an algebraic function to achieve that initial sizing as a function of view width.

Makes sense, thank you!

Arnavop commented 5 months ago

i am still facing this issue is there any fix available?