Jump to content
Search Community

SplitText and ScrollTrigger do not always produce the same result

konstantinschuette test
Moderator Tag

Go to solution Solved by PointC,

Recommended Posts

Demo: https://codesandbox.io/s/youthful-glitter-wrwi0l

Make sure your browser is at least 635px wide, so that it has no horizontal scrollbars.

 

This how it looks, when you open it on the first time or in a incognito tab (not displayed correctly):

image.png.12efe2a64915f9a5c128683781d055b3.png

 

After a browser refresh in Codesandbox, it will be displayed correctly:

image.png.222b4ec34240577958b61dc2f6ef4504.png

 

What could cause this behaviour?

Link to comment
Share on other sites

Seems like the font is not loaded early enough.

Because wrapping the GSAP code with `

document.fonts.ready.then(() => {[...]})

`

seems to do the trick.

 

But now on the first time visiting the page, the text flashes, before the font is loaded.

Is there any way to prefetch the font, so that the first rendering is always happening with that font?

I looked up all the possible `rel` attributes for the HTML link tag, but none seem to fit this (https://3perf.com/blog/link-rels/)

Link to comment
Share on other sites

You can also change the font-display to tell it how to load the font. Right now you have it set to swap, which will show the fallback first.

 

https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display

https://css-tricks.com/almanac/properties/f/font-display/

 

Quote
  • swap: Instructs the browser to use the fallback font to display the text until the custom font has fully downloaded. This is also known as a “flash of unstyled text” or FOUT.

 

image.png

 

  • Like 2
  • Thanks 1
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...