Jump to content
Search Community

How to animate numbers from array

Oskar 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

Hello I am trying to animate numbers which I will get from an API while rendering it into viewport. I have tried to do so but in my case all the instance of numbers are getting updated but I want each number should be updated upto the value I have got from API. How can I achieve this? Here is what I have tried.

 

 

Thank You!

See the Pen agNePM by patrickjane (@patrickjane) on CodePen

Link to comment
Share on other sites

Hello and welcome. This question isn't very related to GSAP, but we'll try to help where we can.

 

You're passing numberCol1 into every renderNumber function call, so it will always animate up to the value of numberCol1, which in the demo is 11 (it will go to 10 since it indexes at 0). 

 

I don't understand what data you'll be getting - why is the first entry different than the later entries? Will it always be in this format?

 

Are you wanting all of the numbers to animate to their value with the same timing? How are you supposed to determine the index? Is it related to the number of entries (in this case 6)?

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