malte-wessel/react-textfit

Often "Freezes" at minimum size

brandonkal opened this issue · 8 comments

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

Did you find a fix?

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.

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

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

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

@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 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!