richie richie - 7 months ago 31
Javascript Question

Using setInterval with countUp.js

How do I get the countup animation to repeat after every 60 seconds. I'm using

countUp.js
for the effect. Tried this;

<script>
var options = {
  useEasing : true,
  useGrouping : true,
  separator : ',',
  decimal : '.2',
  prefix : '',
  suffix : ''
};
var ignite = new CountUp("sales", 0, 332.83, 1, 15, options);

setInterval(ignite.start(), 60*1000);

</script>

Answer

You can see this code working in this fiddle (https://jsfiddle.net/z60sxotr/1/):

var options = {
  useEasing : true, 
  useGrouping : true, 
  separator : ',', 
  decimal : '.2', 
  prefix : '', 
  suffix : '' 
};
var ignite = new CountUp("sales", 0, 332.83, 1, 2, options);
ignite.start();

setInterval(function(){
ignite.reset();
ignite.start()

},60 * 1000);
Comments