Jump to content
Search Community

ScrollTrigger.scrollerProxy stopped after route change

ferriss test
Moderator Tag

Go to solution Solved by GreenSock,

Recommended Posts

Hi,

 

Using the attached codepen, I have this working fine. But when setup in a NuxtJS or equivalent environment with ajax route changes the ScrollTrigger.scrollProxy stops calling.

 

I've tried ScrollTrigger.kill() on the destroyed() method of NuxtJS, but whenever I go back to the route with the setup, scrollTop() doesn't call within ScrollTrigger.scrollProxy.

 

Thanks

See the Pen ExPdqKy by GreenSock (@GreenSock) on CodePen

Link to comment
Share on other sites

  • Solution

I believe that's resolved in the upcoming release which you can preview at https://assets.codepen.io/16327/ScrollTrigger.min.js 

 

And here's a .tgz file with the public stuff (in beta) that you can npm install: https://assets.codepen.io/16327/gsap-beta.tgz

 

Better? 

 

If you need a workaround for the current version, let me know. Basically it's caching the first scrollerProxy for that particular element - I hadn't anticipated anyone creating multiple scrollerProxies for the same element. So you could just create a variable that keeps track of the latest "this.locoScroll" in your file (the LocomotiveScroll object) and then reference that in your scrollTop getter, like yourVariable.scroll.instance.scroll.y

  • Like 1
  • Thanks 2
Link to comment
Share on other sites

  • 1 year later...

Hi @nazanin. This is a very old thread and that fix has been out for a very long time. If you're running into trouble, please post a minimal demo (like in CodeSandbox or CodePen). Also, make sure you kill() all the old ScrollTriggers when you do your routing change. An easy way to do that is: 

ScrollTrigger.getAll().forEach(t => t.kill());

 

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