Jump to content

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

Steps Easing: Access current step in onUpdate?

Recommended Posts

Hi. Is there a way to get the current step # in onUpdate callback when using ease: 'steps(123)'? I was spending the last hour trying so, but without any luck. I could read out the current backgroundPositionX and use that to recalculate the current step #. But that is not very performant and more a workaround. I bet there is a smarter way to achieve that in GSAP, right? :)

Link to comment
Share on other sites

Hey Simon. Given that steps are linear (unless you mix it with another ease) you should be able to get the current step by using the tween's progress. For example:

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

Link to comment
Share on other sites

Thanks. Zach. That is exactly how I ended up. Works like a charm... I just thought there might be a more elegant solution. But it's still pretty straight forward! I can totally live with that.

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.