AkhilRaja Posted July 10, 2021 Share Posted July 10, 2021 i created a very simple scroll trigger animation, and i want to use gsap scrollTrigger "Rich callback system" onLeave: () => action.timeScale(2).reverse(), to speed up the reverse animation on leaving the the div See the Pen RwVGQxg?editors=1010 by AkhilRaja (@AkhilRaja) on CodePen Link to comment Share on other sites More sharing options...
OSUblake Posted July 10, 2021 Share Posted July 10, 2021 Hi Akhil! action isn't defined. Callbacks pass in the scroll trigger instance, which has a reference to the animation. And if you change the timeScale on leave, you would need to reset when it enters. TimeScale when reversed should be negative. So try using this callback instead. onToggle: ({ animation }) => { let timeScale = animation.reversed() ? -2 : 1; animation.timeScale(timeScale); }, 2 Link to comment Share on other sites More sharing options...
AkhilRaja Posted July 10, 2021 Author Share Posted July 10, 2021 29 minutes ago, OSUblake said: onToggle: ({ animation }) => { let timeScale = animation.reversed() -2 : 1; animation.timeScale(timeScale); }, i use this code (copy paste) and it didn't work Link to comment Share on other sites More sharing options...
AkhilRaja Posted July 10, 2021 Author Share Posted July 10, 2021 then i do this and its also not work onEnter: () => HomePageScrollTrigger.play().timeScale(1), onLeave: () => HomePageScrollTrigger.reverse().timeScale(5), onEnterBack: () => HomePageScrollTrigger.play().timeScale(1), onLeaveBack: () => HomePageScrollTrigger.reverse().timeScale(5), Link to comment Share on other sites More sharing options...
AkhilRaja Posted July 10, 2021 Author Share Posted July 10, 2021 onEnter: () => HomePageScrollTrigger.play().timeScale(-5), onLeave: () => HomePageScrollTrigger.reverse().timeScale(5), onEnterBack: () => HomePageScrollTrigger.play().timeScale(-5), onLeaveBack: () => HomePageScrollTrigger.reverse().timeScale(5), this also didn't work Link to comment Share on other sites More sharing options...
AkhilRaja Posted July 10, 2021 Author Share Posted July 10, 2021 54 minutes ago, AkhilRaja said: i created a very simple scroll trigger animation, and i want to use gsap scrollTrigger "Rich callback system" onLeave: () => action.timeScale(2).reverse(), to speed up the reverse animation on leaving the the div @OSUblake can you add codes here and test it thank you! Link to comment Share on other sites More sharing options...
GreenSock Posted July 11, 2021 Share Posted July 11, 2021 I think you meant something like: onToggle: self => self.animation.timeScale(self.isActive ? 1 : -2) Right? 1 Link to comment Share on other sites More sharing options...
Solution OSUblake Posted July 11, 2021 Solution Share Posted July 11, 2021 5 hours ago, AkhilRaja said: i use this code (copy paste) and it didn't work Sorry, I forgot to add the ? to the ternary. onToggle: ({ animation }) => { let timeScale = animation.reversed() ? -2 : 1; animation.timeScale(timeScale); }, 1 Link to comment Share on other sites More sharing options...
AkhilRaja Posted July 11, 2021 Author Share Posted July 11, 2021 14 hours ago, GreenSock said: I think you meant something like: onToggle: self => self.animation.timeScale(self.isActive ? 1 : -2) Right? Thank you so much for helping me its worked 😊 Link to comment Share on other sites More sharing options...
AkhilRaja Posted July 11, 2021 Author Share Posted July 11, 2021 12 hours ago, OSUblake said: Sorry, I forgot to add the ? to the ternary. onToggle: ({ animation }) => { let timeScale = animation.reversed() ? -2 : 1; animation.timeScale(timeScale); }, Yes this work now thank you for always helping me 😊 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