I have two different timer bars that each winds down over 5 seconds. But when I try to stop and reset the first timer, it won't reset, only continues from where it stopped.
Desired behavior: Timer1 starts User hits key Timer1 stops halfway complete Timer2 starts Timer2 expires Timer1 resets to 100% and starts
This is how the timer1 starts:
function StartTimer1(){
$("#timer-bar").show().width("100%");
$("#timer-bar").hide({
effect: "blind",
easing: "linear",
duration: 5000,
direction: "left",
complete: function () {
//do stuff
}
});
}
Then when someone hits a key, I run
//Stop timer1
$("#timer-bar").stop(true, false);
//Start timer2
$("#answer-timer-bar").hide({
effect: "blind",
easing: "linear",
duration: 5000,
direction: "left",
complete: function () {
//do stuff
}
});
Then after timer2 expires, I hit another key which calls StartTimer1() again. And even though I reset the width to 100% before I start the animation, it just continues from wherever it first stopped. I read about queues and thought that was my answer, but I've tried adding unique queue names to each of the timer options, but whenever I do that the timer never starts for some reason. Same when I just set queue to true. I've tried the different options for clearQueue and jumpToEnd parameters when calling Stop(), but can't seem to get the behavior I want.
Any help would be appreciated. Thanks.
JSFiddle: https://jsfiddle.net/58rzg6w0/7