Jump to content
Search Community

ScrollTrigger with spa

Robero test
Moderator Tag

Recommended Posts

Hi there!

 

I'm using ScrollTrigger with BarbaJs, which basically on route change inject in the dom the content of the new route.

When the content change, ScrollTrigger doen't work very well, it doesn't watch for changes in the dom. I have tried using refresh, update, enable and disable, but when the content change it doesn't "reinitialize".

Is there any way I can completery "reset" the ScrollTrigger instance and reinitialize it on page leave/enter?

 

Thank you!

 

Link to comment
Share on other sites

6 hours ago, Robero said:

it doesn't watch for changes in the dom.

Correct. That'd be expensive performance-wise. ScrollTrigger is hyper-optimized for speed. 

 

6 hours ago, Robero said:

I have tried using refresh, update, enable and disable, but when the content change it doesn't "reinitialize".

Is there any way I can completery "reset" the ScrollTrigger instance and reinitialize it on page leave/enter?

You should be able to simply call ScrollTrigger.refresh() to force all the ScrollTriggers to re-calculate their positions. If you're having trouble, please provide a reduced test case with only the absolutely essential code (literally one <div> if possible). It doesn't need to be your actual project - we just need to see it breaking in the context. We'd love to help, but it's tough to troubleshoot blind, that's all. 

  • Like 1
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...