Jump to content
Search Community

Number of onUpdate Calls?

uiguy test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

I have an animation where I'm changing a numeric value with each onUpdate call. its a canned animation. What I'm finding is different browsers have a different number of times its callback - id always like to finish *almost* at my final number. I can figure this out with a little math but need to know how many times the onUpdate will fire before it runs - is this possible?

Link to comment
Share on other sites

That's totally normal. Not all browsers run at a perfect 60fps all the time. There are MANY factors that go into that (computer performance, other background tasks, etc.). That has nothing to do with GSAP, by the way.

 

I'd strongly recommend never writing code that assumes a certain number of onUpdates or requestAnimationFrame ticks. Well, I suppose there could be some rare situations where it'd be appropriate but it's extremely uncommon.


Can you help us understand why you're trying to build something that's dependent on a certain number of onUpdates? If you want to animate to a value but never quite reach it, can't you simply adjust the target value (reduce it slightly)? 

 

  • Like 2
Link to comment
Share on other sites

Agreed - I was going to dynamically change how much to change the number by based on how far along the animation was. After posting I stumbled upon this which I think covers my needs:

 

For my specific project - I have a long table of values that Im quickly animating and I have another larger element thats "ticking up" (or summing, however fake) all those rows. I want both animations to end at the same time and appear to be in conjunction.

 

I added a sloppy pen of what Im doing

 

See the Pen YLjYPP by mrtips (@mrtips) on CodePen

 

Link to comment
Share on other sites

7 minutes ago, GreenSock said:

Ah, okay. Well, you could also just use roundProps and simplify things a bit: 

 

 

 

oh wow - I'm not familiar with roundProps but at a quick glance its exactly what I want - thank you!

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