richie
richie

Reputation: 18638

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>

Upvotes: 0

Views: 371

Answers (1)

Anderson Contreira
Anderson Contreira

Reputation: 798

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);

Upvotes: 1

Related Questions