MarcusG Posted September 29, 2023 Share Posted September 29, 2023 I'm currently incrementing some text from 0 to 100 perfectly, but I was wondering if it's possible to do so using leading zeros – e.g. 001 to 100 gsap.from('.number', {innerText: 0, duration: 3, snap: {innerText: 1} }); Link to comment Share on other sites More sharing options...
Solution mvaneijgen Posted September 29, 2023 Solution Share Posted September 29, 2023 Hi @Marcus Griffen welcome to the forum and thanks for being a Club Greensock member 🎉 A minimal demo would have been nice here, so that we don't spend the first 5 minutes creating a demo our selfs and can jump in the code directly, keep that in min for next time 🙃 I've used the modifier property to update the value based on your requirements, the snap logic doesn't work with it, so you have to round the number in the function your self. And the zeroPad function comes from stackoverflow. Hope it helps and happy tweening! See the Pen bGOKjRj?editors=0011 by mvaneijgen (@mvaneijgen) on CodePen 2 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now