Jump to content
Search Community

SplitText lines are not splitting properly

Alphamark test
Moderator Tag

Go to solution Solved by mvaneijgen,

Recommended Posts

I'm creating a website in webflow and I have a split text animation, and sometimes this happens on mobile.image.png.9530c15c157a78ac78ea9d43c547fa02.png

I think I found out what the problem is — splitText splits the lines before the font is loaded (when the text is smaller), I inserted the font locally, and now it happens only sometimes, not all the time. But it still happens, so can someone help me and tell me if is there a workaround for this?

Link to comment
Share on other sites

Posted (edited)

@mvaneijgen Thanks a lot mate! That helped.

I used the onloadingdone event, which waits for the font to finish loading. The code is down below if someone has the same problem.

document.fonts.onloadingdone = () => {
  splittext_code_goes_here;
};

(async () => {
  await document.fonts.load("16px YOUR_FONT");
})();

 

Update:

For some reason, the event doesn't work on iOS.

Update 2:
I don't know why the code above doesn't work on iOS even if it has support for it. I found this code instead to work fine on iOS and other devices as well.

async function isReady() {
  let ready = await document.fonts.ready;
  console.log(ready);
}

isReady()
Edited by Alphamark
Code updated
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...