Hi everyone! I'm working on a page where a want an animation to happen when the user navigates to a certain page on my website, but kill it on other pages. I'm running this code when the user navigates to the site where I want the animation to happen:
logoAnimation: (app) => {
app.logo.hasBeenAnimated = true;
const paths = document.querySelectorAll("#logo .path");
paths.forEach((path, i) => {
const index = i / (paths.length - 1);
gsap.to(path, {
scrollTrigger: {
id: "logoPaths",
trigger: "body",
scrub: 7,
start: `${index * 10}% top`,
end: `${index * 60 + 60}% bottom`,
},
rotate: gsap.utils.random(-25, 25),
opacity: 7,
ease: "circ.out",
});
});
},
and this code when a user navigates to another page:
if (app.logo.hasBeenAnimated) {
let pathsTrigger = ScrollTrigger.getById("logoPaths");
pathsTrigger.kill();
}
},
And that's not working. The only thing that works is to kill all ScrollTrigger animations, but I just want to destroy this one. How can I do that?