Robero Posted June 15, 2020 Share Posted June 15, 2020 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 More sharing options...
GreenSock Posted June 16, 2020 Share Posted June 16, 2020 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. 1 Link to comment Share on other sites More sharing options...
ZachSaucier Posted June 16, 2020 Share Posted June 16, 2020 Also note that if you are switching out the DOM elements that ScrollTrigger is applied to then you'd need to reapply ScrollTrigger to those elements. Same thing for any new elements that you're wanting ST to affect. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now