Jump to content
Search Community

Issue writing several scrollTriggers

Michaël Garcia test
Moderator Tag

Recommended Posts

On the back office of my website, the client can build pages using modules in the order he wants (for examples he can creates several horizontal scrolls or several pined sections)

 

On the front side, I do something like this

 

// declarations

document.querySelectorAll('.slider').forEach(slider => {
  // my scrolltriggers
  gsap.to('....', {
    scrollTrigger:slider,
    ...
  });
});

document.querySelectorAll('.horizontalScroll').forEach(horiS => {
  // my scrolltriggers
  gsap.to('....', {
    scrollTrigger:horiS,
    ...
  });
});
  
ScrollTrigger.refresh();

 

Unfortunately I can't chose the order of the sections in the DOM and I noticed it creates weird issues (regarding the start and end positions of all my scrollTriggers) . Even if I refresh all my scrollTrigger in the end, a lot of the trigger are not correctly set. 

 

Does anyone has good advices to prevent this behavior ? 

Thanks a lot. 

 

 

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