Jump to content
Search Community

quick flash/disappear/appear/jump in translateX when setting it before animation

David12345 test
Moderator Tag

Recommended Posts

Hi Everyone,

 

I have a timeline (React based app) where the translateX is set with set at the very beginning of the timeline with no transition, then the translateX position is animated. From time to time (every 5 occurrences when I hit refresh and replay the timeline) there is a quick flash/disappear/appear/jump in the translateX. This happens even if I set with .set, .quickSetter or .to with 0 transition.


Does anyone have an idea why this might be happening?

Link to comment
Share on other sites

That sounds like the "flash of unstyled content" gotcha. Please see this: 

 

It's not a bug or issue with GSAP - it's simply due to the fact that the browser CANNOT run the JS until things are adequately loaded and parsed, so you'll often see things showing in the original state and then BOOM when the JS executes it looks the way you intended. Solution: set the initial state in CSS. I'd strongly recommend also setting at least the transforms via GSAP too (even if it's set in the CSS) because it allows GSAP to cache it (boost performance) and it also ensures accuracy. See this article: 

 

Happy tweening!

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

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...