I'm wondering if there was a way to "pause" a javascript setInterval
command and then resume it a few seconds later, then go through the loop, pausing for a while, start looping again, pausing again etc.? In other words, when a logical condition is right, pause for a set amount of time before picking up again?
Using pseudo code, I was thinking something like:
setInterval(fn, 1000);
pausecondition = false;
fn()
{
// do stuff, including pausecondition
if (pausecondition == true)
{
// pause for two seconds
// pausecondition = false
}
}
What I'm trying for is a setInterval
that works every 1000 milliseconds, then when the pause condition is true, the function pauses for two seconds and then setInterval resumes every 1000 milliseconds as before.