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

Different classes for each number #159

Closed voitin closed 6 years ago

voitin commented 6 years ago

Hello,

Is it possible to add a different class to each number (0-9) so I can style each of them individually (add a background image for each of them)?


Update (if you need this feature)

Add after the following line in Odometer.prototype.animateSlide:

addClass(numEl, 'nr'+frame);

This one:

numEl.className = 'odometer-value';

And also add in Odometer.prototype.addDigit after:

digit.querySelector('.odometer-value').innerHTML = value;

This line:

digit.querySelector('.odometer-value').classList.add('nr'+value);

And all your digits will now have .nrX class added so you can style them how you want :)