CountUp.js is a dependency-free, lightweight JavaScript "class" that can be used to quickly create animations that display numerical data in a more interesting way.
Despite its name, CountUp can count in either direction, depending on the startVal
and endVal
params that you pass.
CountUp.js supports all browsers.
The only file you need is countUp.js.
If you want to get fancy with build systems, a gulpfile is included. Read more here.
Params:
target
= id of html element, input, svg text element, or var of previously selected element/input where counting occursstartVal
= the value you want to begin atendVal
= the value you want to arrive atdecimals
= (optional) number of decimal places in number, default 0duration
= (optional) duration in seconds, default 2options
= (see demo, optional) formatting/easing options object
Decimals, duration, and options can be left out to use the default values.
var numAnim = new CountUp("SomeElementYouWantToAnimate", 24.02, 99.99);
numAnim.start();
with optional callback:
numAnim.start(someMethodToCallOnComplete);
// or an anonymous function
numAnim.start(function() {
// do something
})
Toggle pause/resume:
numAnim.pauseResume();
Reset an animation:
numAnim.reset();
Update the end value and animate:
var someValue = 1337;
numAnim.update(someValue);
- Details on the license can be found here
- Details on running tests and contributing can be found here