inorganik / countUp.js

Animates a numerical value by counting to it
https://inorganik.github.io/countUp.js
MIT License
8.03k stars 1.38k forks source link

request: define step value #176

Closed codemonkeynorth closed 7 years ago

codemonkeynorth commented 7 years ago

Hi,

it would be useful to be able to supply a step number.... ie to count to 10000 in 1000's

0 1000 2000 etc

thanks J

inorganik commented 7 years ago

This could be easily accomplished by passing a custom formatting function:

var options = {
    formattingFn: function(num) {
        var result = Math.round(num / 1000) * 1000; // round to nearest 1000
        return result
    }
}

var demo = new CountUp("myTargetElement", 0, 10000, 0, 2.5, options);
demo.start()

http://jsfiddle.net/wgLyn1gg/

codemonkeynorth commented 7 years ago

ah great thanks