Jump to content
Search Community

Gsap ScrollTrigger Snap disturbing whole app

Ahmad-dev test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Gsap ScrollTrigger Snap disturbing the whole app while I'm a using it only in a single component
It snaps different sections automatically up and down
is there any solution for this?

 

const panels = gsap.utils.toArray("#panels-container .panel");
tween = gsap.to(panels, {
xPercent: -100 * (panels.length - 1),
ease: "none",
scrollTrigger: {
trigger: "#panels-container",
pin: true,
start: "top top",
scrub: 1,
snap: {
snapTo: 1 / (panels.length - 1),
inertia: true,
duration: { min: 0.1, max: 0.1 },
},
end: () => "+=" + (panelsContainer.offsetWidth - innerWidth)
}
});
Link to comment
Share on other sites

  • Solution

Yeah, a minimal demo will definitely be necessary to know for sure, but this sounds like either you forgot to kill() the ScrollTrigger when you reroute (are you using a framework like Nuxt/React or something?) or you're misunderstanding how snapping gets applied and have that ScrollTrigger set up in an area on the screen that you don't actually want snapping to occur. Again, very difficult to know without seeing a minimal demo. But if you're rerouting to a different page without the normal browser redirect, definitely make sure you .kill() that ScrollTrigger instance. 

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