A counter that uses a timing function to move towards it's destination.
Check out the live demo on CodePen, which uses the stand-alone file.
Ensure component(1) is installed, then:
$ component install tanem/tweening-counter
This library may be used stand-alone without the component tool. To build the stand-alone files, ensure UglifyJS2 is installed, then:
$ make standalone
Then add ./tweening-counter.js to your application and reference the TweeningCounter
global.
To run the unit tests, ensure testling is installed. Then:
$ make test
Initialize a new TweeningCounter
with the given el
.
Set the value to tween to.
tweeningCounter.to(50)
Set the easing function.
tweeningCounter.ease('in-out-sine')
tweeningCounter.ease(function(){})
Set the easing duration.
tweeningCounter.duration(1000)
Add an end
event handler bound to this TweeningCounter
.
tweeningCounter.onEnd(function(){})
Specify the number of decimal places in the output.
tweeningCounter.fixed(2)
Start the counter.
tweeningCounter.start()
MIT