Jump to content
Search Community

scrollTrigger not working in combination with transition CSS

colehoward test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

  • Solution

Welcome to the forums, @colehoward

 

First of all, thanks for providing such a wonderful minimal demo! I wish every forums post had one of those. It makes it sooo much faster and easier to know exactly what's going on. 🙌

 

I'd definitely recommend avoiding CSS transitions, especially on anything that will be affected by JavaScript. 

 

The reason it's doing that is because in order for ScrollTrigger to do its pinning magic, it must set the top/left values and do some calculations with getBoundingClientRect() to make it appear to stay stuck in the same spot. Here's a CodePen that simplifies the general concept into a setTimeout() that runs 500ms after the page loads (and doesn't use GSAP/ScrollTrigger):

See the Pen OJWBVoM?editors=0010 by GreenSock (@GreenSock) on CodePen

 

When you have CSS transitions applied to all properties, it basically tells the browser "anytime something changes, don't make that change right away - instead, drag that out across X seconds". As you can imagine, if you animate something with GSAP and it has CSS transitions applied to it as well, GSAP will set the property to a new value 60 times per second, but the CSS transitions will jump in and try to make that gradual. It's not only bad visually, but it's craptastic for performance :)

 

Does that clear things up? 

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