Skip to content
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

Initial fontSize value is not updated and onStart/onFinish do not fire #12

Open
Nantris opened this issue Dec 18, 2020 · 5 comments
Open

Comments

@Nantris
Copy link

Nantris commented Dec 18, 2020

I'm not sure what the issue is, because we use useFitText in one other place and it works, but in this other circumstance it simply defaults to the specified maxFontSize, even if that means it wraps lines. It's the same whether we use a width specified in pixels or percentages, whether we set a height on the element, whether we set overflow: hidden - whether we change the text or resize the window. Nothing happens under any circumstances. Any thoughts?

@saltycrane
Copy link
Owner

hi @slapbox, I'm not sure if I can solve it, but if you can create a reproduction example by forking this Codesandbox https://codesandbox.io/s/use-fit-text-basic-example-qpo04?file=/pages/index.js it would be helpful.

@Nantris
Copy link
Author

Nantris commented Jan 7, 2021

Hey @saltycrane thanks for your reply and for the great library!

I've been trying like hell to make a repro case, but no such luck. Do you have any "shot in the dark" ideas about things we might look into?

I've even tried poking around in the index.js of the library, although it's the minified version and I wasn't able to find any clues. I'm pretty much at a total loss for where to look for clues about either the cause or a possible solution.

All I was able to notice from setting breakpoints in the index.js is that it all runs when I'd expect - it just doesn't run the callbacks or update the font size.

@Nantris
Copy link
Author

Nantris commented Jan 7, 2021

I just got it to work once, but I have no idea how. I was playing around with resize: both; overflow: hidden to allow manual resizing (which didn't trigger useFitText) but then at some point it suddenly began to, perhaps after a hot reload? I haven't been able to achieve that again though.

@saltycrane
Copy link
Owner

hi @slapbox thanks for trying to provide a repro example and trying to debug the code. You mentioned trying to use the minified version of the source code. You could also try copy and pasting the source code here into your project so you can debug the non-minified source code. So did you see that the useFitText hook was invoked but onStart was not? I would look at this code: https://github.com/saltycrane/use-fit-text/blob/master/index.ts#L64-L95 I think that code can actually be refactored to be simpler, but I'm not sure if that would affect your issue.

@nicolabosco87
Copy link

Maybe I have replicated this bug. Could not handle correctly conditioanl rendering. Added infos into a MR #29

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants