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

SplitType not working as expected in WebFlow project #56

Open
dongepulango opened this issue Feb 7, 2023 · 10 comments
Open

SplitType not working as expected in WebFlow project #56

dongepulango opened this issue Feb 7, 2023 · 10 comments

Comments

@dongepulango
Copy link

dongepulango commented Feb 7, 2023

I have no idea what's causing this bug. When i go to my page, sometimes it will split the lines correctly and sometimes it will split additional line. I get the bug 1 out of 10 if I do refresh, mostly when i first open the tab with the link.

Please help how can I prevent this. thanks

Correct:
Screenshot 2023-01-17 at 19 26 46

With bug:
Screenshot 2023-01-17 at 19 26 21

Here is the link: https://creatd-bb.webflow.io/

@beanduong
Copy link

beanduong commented Feb 8, 2023

It might have something to do with your font loading. Your font gets loaded after the DOM, so because the fallback font is wider than your own font, CURRENCY will cause a line break.

When I open your page for the first time, I get that behaviour. Afterwards, the font gets cached and loads with the DOM on refresh.

@lukePeavey
Copy link
Owner

It's rendering correctly every time on my end. Were you able to fix the problem?

I think it was probably due to font loading as @beanduong suggested.

@dongepulango
Copy link
Author

It might have something to do with your font loading. Your font gets loaded after the DOM, so because the fallback font is wider than your own font, CURRENCY will cause a line break.

When I open your page for the first time, I get that behaviour. Afterwards, the font gets cached and loads with the DOM on refresh.

Any recommendation how to fix the problem? tried font-display: auto; and still the same. What I had before was font-display: swap;. Not even sure if that CSS will fix that problem.

It's rendering correctly every time on my end. Were you able to fix the problem?

Not yet, still testing it.

@beanduong
Copy link

CSS-Tricks has a good article on Flash of unstyled text (FOUT).

I have personally used webfontloader to wait for the fonts to be loaded, but the font style matcher approach looks good, too.
If you are using Nextjs, @next/font does the preloading for you.

@dongepulango
Copy link
Author

CSS-Tricks has a good article on Flash of unstyled text (FOUT).

I have personally used webfontloader to wait for the fonts to be loaded, but the font style matcher approach looks good, too. If you are using Nextjs, @next/font does the preloading for you.

Thanks for the help, I will check it out. We are using Webflow for this project.

@lukePeavey
Copy link
Owner

Try setting the font family on the heading to system fonts and see if the problem still occurs. If this eliminates the problem, then it is definitely due to SplitType being called before your font has loaded.

@JonQuayle
Copy link

JonQuayle commented Mar 3, 2023

This is also something I have been experiencing for a while. I'm using Next js (13), even using the next/font package doesn't really solve this. It seems to be completely random also. For example, I reuse the hero design across my site, so the titles are very similar in length, same font style and size, 2 out of the 4 pages might be fine, but the other two will have one word on each line. Setting the font to system also has no effect.

@gogumai
Copy link

gogumai commented Aug 9, 2023

Hi @dongepulango , were you able to fix this? I'm also using Webflow and experimenting the same issue, thanks!

@suhaylmv
Copy link

suhaylmv commented Sep 5, 2023

CSS-Tricks has a good article on Flash of unstyled text (FOUT).

I have personally used webfontloader to wait for the fonts to be loaded, but the font style matcher approach looks good, too. If you are using Nextjs, @next/font does the preloading for you.

Thanks, this solved it for me. If I were you, I would create a troubleshooting section in the readme and include this, since it seems to be a common issue

@Abdox3
Copy link

Abdox3 commented Sep 9, 2023

A workaround is to lower the font size after splitting

@lukePeavey lukePeavey changed the title Split Line bug SplitType not working as expected in WebFlow project Oct 21, 2023
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

7 participants