I need my code to run x amount of times and then pause for 30 seconds or so before resuming. Any ideas?
myslidefunction();
var tid = setInterval(myslidefunction, 1000);
function myslidefunction() {
setTimeout(function () {
//do stuff
}, 400);
};
You can keep a run-count, and use normal_duration + 30000
as the setTimeout
delay for the X+ 1st time.
var runCount = 0, runsBeforeDelay = 20;
function myslidefunction(){
// .. stuff
runCount++;
var delay = 0;
if(runCount > runsBeforeDelay) {
runCount = 0;
delay = 30000;
}
setTimeout(myslidefunction, 400 + delay);
};
// start it off
setTimeout(myslidefunction, 1000);
var counter = 0;
var mySlideFunction = function(){
/* your "do stuff" code here */
counter++;
if(counter>=10){
counter = 0;
setTimeout(mySlideFunction, 30000);
}else{
setTimeout(mySlideFunction, 1000);
}
}
mySlideFunction();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With