HubSpot / odometer

Smoothly transitions numbers with ease. #hubspot-open-source
http://github.hubspot.com/odometer/docs/welcome
MIT License
7.3k stars 712 forks source link

Respect Leading Zeros in Initial Render Pass #156

Open Kelderic opened 6 years ago

Kelderic commented 6 years ago

Currently, an element that is initialized while having a textContent of "000", will be shown as "0". This commit takes a snapshop of the initial value, and then uses that snapshot in the initial render pass, rather than converting the string to a number and then back to a string. This respects leading zeros.

eads commented 5 years ago

This is neat, but didn't work for me ... only doing this during the initial rendering pass caused problems after the initial rendering pass. If I have time I might play with this to respect zero fill during every render pass.

I think this is a great approach to the zero fill problem -- simply let the value dictate how to zero-fill.