MiffyWu Posted March 28 Share Posted March 28 scrolltrigger use pin and once, but pin-spacer cause padding space when scroll back I want it run once , when scroll back it show self.progress(1) without pin-spacer how can i do~~ pls help~~ See the Pen NWmveEK?editors=1010 by Miffy402 (@Miffy402) on CodePen Link to comment Share on other sites More sharing options...
Solution GreenSock Posted March 28 Solution Share Posted March 28 You're making one of the common ScrollTrigger mistakes - nesting ScrollTriggers inside of a timeline. That can't logically work because you can't have the parent timeline AND the scroll position both control the same playhead(s), as they could be going in different directions. So either separate out each tween into its own individual tween that has a ScrollTrigger on it, OR put your tweens into a timeline that has a ScrollTrigger applied to that timeline. As for once: true, you could do something like this instead: onLeave: self => { let max = ScrollTrigger.maxScroll(window), // record maximum scroll amount, and the current scroll position scroll = self.scroll(); self.kill(true, true); self.scroll(scroll - (max - ScrollTrigger.maxScroll(window))); // adjust the scroll based on how much was lost when self.kill() was called. } See the Pen jORLdmy?editors=0010 by GreenSock (@GreenSock) on CodePen (I didn't fix all your nested ScrollTriggers - you'll need to work through those). 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