Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
alexandrebuffet

Trying to limit velocity when updating timeScale on scroll

Recommended Posts

Hi there,

 

I'm trying to speed rotation animation on scroll with use of ScrollTrigger.

 

It works pretty well except when I do a fast scroll the rotation gets crazy and I don't really know how to limit the speed...

Maybe I do it all wrong, I tried to clamp value but any ideas on how to limit that correctly?

 

Thanks for your help !

 

Alex

See the Pen QWEyGYp by alexandrebuffet (@alexandrebuffet) on CodePen

Link to post
Share on other sites

The reason it "gets crazy" (keeps going fast at the end) is just because that's what the velocity is at the end of the scroll (fast). It doesn't keep updating the velocity after that (onUpdate only gets called when the actual scroll position changes). So it's behaving as expected. 

 

I'm not sure what behavior you want exactly, but if you want the rotation to return to its "normal" speed after scrolling, you could do something like this: 

See the Pen fb6d6dc923b36facb2020f4da7ef63ef?editors=0010 by GreenSock (@GreenSock) on CodePen

 

I'm just setting the timeScale based on velocity like you were, but tweening it back to 1 over the course of 2 seconds. 

 

Does that help? 

  • Like 4
Link to post
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.

×