Search the Community
Showing results for tags 'numbers'.
Found 2 results
Hi there! I would like to add a scalar tween to a component in React using GSAP, the component is a functional component. I've whipped up a quick example of how i think that could be implemented in React using GSAP in the attached codepen. (Type in some number values into the input and watch GSAP tween the number below the input) It's a bit dirty as i need to add a global object to the window on the first mount of the component, so that GSAP has an object it can freely mutate without React resetting it on each render. Is there are better way of allowing GSAP to perform a scalar transition within React? Thanks for any help you can give!
I've done most of the hard lifting here, instead of going +5 or -5 I want to be able to cycle through a list of numbers with no correlation to each other- var numbers = ["330", "477", "20", "128", "8"] Preferably I'd like to count up/down between values in the thousands/millions, so a big bonus would be to represent them with a k or and m at the end. For Example: var numbers = ["330", "477", "20", "128", "8"] var values = ["k", "k", "m", "k", "m"] But outputting like: (number, value) or 330k, 447k, 20m etc... I've stripped down the example to like 20 lines of code to it's easy to see what's going on. My guess is I'd have to do the k/m separately and output in a separate field next to it, if there's an easier way I'd love to know though! Cheers, Will