react-textfit icon indicating copy to clipboard operation
react-textfit copied to clipboard

Issue calculating the font size

Open santigimeno opened this issue 7 years ago • 4 comments

I'm new to react and just started using this component so maybe my observations are far from correct but there we go.

My issue is that sometimes the font-size calculated is by far too small. By adding some logs I've observed that the issue was that the originalWidth calculated at first wasn't correct (it returned a less width of what it should) so the algorithm resulted in an incorrect font-size. I corrected the issue by making sure that every time the algorithm called assertElementFitsHeight and assertElementFitsWidth the innerWidth and innerHeight was retrieved again from the element. Does this make any sense?

Thanks!

santigimeno avatar Jun 21 '17 18:06 santigimeno

Thank you for details provided in the post. Do you think you could demonstrate an example using something like jsfiddle.net, or a fork or any tooling of your choice?

denis-sokolov avatar Jun 23 '17 22:06 denis-sokolov

https://codesandbox.io/s/73AJMQ7jO Hi, I have created a demo. Font unpredictably enlages by clicking.

StipJey avatar Jul 03 '17 09:07 StipJey

@StipJey thanks for the example. That's exactly what I'm observing

santigimeno avatar Jul 03 '17 09:07 santigimeno

Beautiful, thank you, @StipJey! Seems like definitely a bug, indeed.

denis-sokolov avatar Jul 03 '17 10:07 denis-sokolov