Jump to content
Search Community

GSAP animation - detect a percentage of animation progress

fd_alistair test
Moderator Tag

Go to solution Solved by akapowl,

Recommended Posts

  • Solution

Hello @fd_alistair

 

You could add an onUpdate eventCallback and check on the progress() of the tween.

 

And then, whenever you gave the warning, make sure to remove the callback.

 

Something like this maybe:

 

See the Pen GRxXGVy by akapowl (@akapowl) on CodePen

 

 

Or as an alternative, use a timeline and add a .call() at whatever point in time you'd like, making use of the position parameter

See the Pen wvmExKY by akapowl (@akapowl) on CodePen


 

Link to comment
Share on other sites

29 minutes ago, akapowl said:

Hello @fd_alistair

 

You could add an onUpdate eventCallback and check on the progress() of the tween.

 

And then, whenever you gave the warning, make sure to remove the callback.

 

Something like this maybe:

 

 

 

 

Many thanks for getting back to me - The first option (the eventCallback) seems to work best, however I've updated the Pen to include the button which decreases the height - basically I need to warn the user when it gets to a certain percentage, the users clicks the 'empty button', the animation starts again and then I need to start the percentage detection process again.

Thanks again

Link to comment
Share on other sites

 

Then you'll need to adjust the logic of your code to work with that. One way you could do it is to pause the waste tween on click (and maybe just in case also reset the eventCallback to null again), tween the progress of the waste tween to 0 and in an onComplete callback of that tween, restart the waste tween again and re-add that eventCallback to the waste tween. Just an idea, maybe give it a shot yourself.

 

  • Like 1
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...