-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Successive renders reapply compressor #4
Comments
Hey, thanks for the issue report. Setting the compressor to For the other part, I’m not able to reproduce it, or maybe I’m misunderstanding. Here’s a comparison against the other Would you mind modifying it or making a new demo that demonstrates the problem? Thanks again. |
Hi @kennethormandy thanks for your response I tried to change the css to closer match my real world app from your example https://codesandbox.io/s/jovial-sara-wrshs?fontsize=14 if you refresh this browser, and then take the browser out of full screen mode and resize the brwoser a few times the text just gets bigger and bigger I'm not sure if this is due to the flex box container |
Thanks, I see what you mean. How about this? https://codesandbox.io/s/eager-resonance-sdjru
Possibly, yes. I see what you mean, but as soon as I changed that It’s also because the other So that’s why the h1 is a different size between the two versions: the parent font size is being set to ex. <h1 className="text">
<FitText compressor={0.5}>The quick brown fox</FitText>
</h1> Or something like: <FitText compressor={0.5}>
<h1 className="text" style={{ fontSize: '1em' }}>The quick brown fox</h1>
</FitText> Let me know how that works out for you. |
thanks @kennethormandy I'll have a play |
Just to clarify, are you looking for the font size to scale to the full size of the container? If so, there are some other options discussed in the README that will solve your problem, that’s not really what FitText is best at. The other React FitText and the original jQuery library doesn’t aim to do this either. As far as I know, the other React FitText library always scales based on the window/body as well, not the parent container, but I can see how that would be useful. I would be open to a Pull Request that builds on the I might also take that opportunity to look at something like react-size-aware to manage this. |
Hi thanks again for your swift response. So I've made a codesandbox that hopefully demonstrates it: https://codesandbox.io/s/confident-snow-iwspo?fontsize=14 If you click the increase /decrease width buttons a few times with the browser un-maximised and then resize the browser you see that this library only updates the content on browser resize whereas |
Thanks very much for the test case, that helps a lot, and I see what you mean. I think it would either make sense to:
If the other |
No worries, maybe if I get some time I can explore creating a PR. |
If i resize the window with this component in with a
compressor value
of <0 the text keeps shrinking and shrinking until its almost invisibleThe same for text that is >1.
Resizes cause it to grow and grow.
This issue didn't happen with
react-fittext
. (I'm trying to do a direct swap of your component with theirs.)The text was updated successfully, but these errors were encountered: