kimmobrunfeldt / progressbar.js

Responsive and slick progress bars

Home Page:https://kimmobrunfeldt.github.io/progressbar.js

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to reset a progress bar to its default position?

djscottworthing opened this issue · comments

Hi, I am using this library to put a timer on a web page, and I want the timer to run multiple times in a row. Is there a way to reset a timer back to its default position? I tried using something along the lines of this:

  bar.animate(1, function() {
    bar.animate(0);
  }); 
}

But it resets the timer by reversing it, and doing the count in reverse (so counting from 0 back to 10). Surely there is a line of code that I am missing that just resets the timer back to how it was when the webpage was loaded. Or a way of running the code above instantly, with no time delay.

Hi. You can use the bar.set() method to reset the counter to 0.

if(true) { bar.set(0); // Resets bar state to 0. }

I hope this helps!

I can't get mine to reset using the above, I keep getting "Uncaught (in promise)" when ever I try to use .set(0)