Jump to content
Search Community

ScrollTrigger Best Practices

AdventurousDeveloper test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hey GSAP fam!

 

Sorry if this type of question has been asked before or an obvious thing...

I've started to build a lot of my client websites using GSAP + ScrollTrigger. Generally a page template would have multiple individual content sections that make use of their own ScrollTriggers and animations etc.. Currently I set each section scrollTrigger to be triggered at the top of a section element and end at the bottom of the said element. This means some pages can end up having 5+ seperate scrollTriggers on them. 

 

Rather than my approach above, I am wondering if it is considered best practice to create a master timeline and then use add() to add all my scrollTriggers to it? I guess this would offer better control positioning etc..?

 

Any advice would be greatly appreciated!

 

Cheers,

Link to comment
Share on other sites

  • Solution
3 hours ago, AdventurousDeveloper said:

Rather than my approach above, I am wondering if it is considered best practice to create a master timeline and then use add() to add all my scrollTriggers to it? I guess this would offer better control positioning etc..?

Definitely not. In fact, that's one of the common mistakes :)

 

You can't have multiple ScrollTriggers inside one timeline. It's logically impossible because the scrollbar -OR- the parent timeline's playhead can control the animation's playhead, not both. 

 

It's tough to offer advice without a minimal demo but you shouldn't be afraid to have 5, 10 or even more ScrollTriggers on one page. It's optimized for performance already.  

 

Enjoy!

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