Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
2malH

Problem with killing and reinitialising ScrollTrigger after Single Page App page transition

Recommended Posts

On 6/8/2021 at 12:32 AM, jltech said:

Something that helped me in Reactjs was to kill all the ScrollTriggers on a page when it dismounts.

 

In the useEffect I have to create the ScrollTriggers I am doing this:

 


useEffect(() => {
  ...
  ...
  return () => {
    // We kill all scroll triggers so the next pages can recreate them.
    const triggers = ScrollTrigger.getAll();
    if (triggers) {
      triggers.forEach((trigger) => {
        trigger.kill();
      })
    }
  };
}, []);

 

Hope this helps someone.

Thanks for your help :)I was trying to destroy my animations after loading barbaJS ;)

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.

×