Jump to content
Search Community

ScrollTrigger toggle actions on leave speed up animation gsap.timeScale()

AkhilRaja test
Moderator Tag

Go to solution Solved by OSUblake,

Recommended Posts

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);
},

 

  • Like 2
Link to comment
Share on other sites

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

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

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

  • Solution
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);
},

 

  • Thanks 1
Link to comment
Share on other sites

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

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