A jQuery plugin to count up a number with start on element visible feature
npm install jquery-counter --save
2. Require jQuery and Counter
<script src="jquery.min.js"></script>
<script src="jquery.counterup.min.js"></script>
or
require('jquery');
require('jquery-counter');
<span data-counter data-offset="100" data-duration="1000" data-delay="1000">400</span>
Through data properties you can set the following parameters:
Prop | Type | Default | Note |
---|---|---|---|
offset |
String |
200 | Element top offset (in pixels) based on view top offset to start the animation |
duration |
String |
3000 | Time (in milliseconds) to count it up |
delay |
String |
200 | Delay (in milliseconds) to start the animation as per the element becomes visible |
$('[data-counter]').counter();
$('[data-counter]').counter({
decimals: 0,
decPoint: ".",
thousandsSep: ","
});
$('[data-counter]').counter('bind');