How to interrupt timeouts for some elements?
Compact syntax with timing methods:
1
2
// $('.some').wait(timeout)…
$('.some').unwait();
Compare this to the old way with more syntactic fluff:
1
2
// var timer = setTimeout(function(){ … }, timeout))
clearTimeout(timer);
Similar patterns with chain interruption
Similar patterns with timeouts
- How to
insert a single timeout?$('.some').doSome().wait(timeout).doLater();
- How to
invoke a single function after a timeout?$.wait(timeout, function(){ … });
- How to
invoke a callback at some specific point in the timeline?$some.timingStuff().then(callback).doMore();
- How to
insert multiple timeouts?$('.some').doSome().wait(first-timeout).jQueryStuff() .wait(second-timeout).doLater().jQueryStuff();
- How to
concatenate function calls with timeouts?$.wait(first-timeout, function(){ … }) .wait(second-timeout, function(){ … }) .wait(third-timeout, function(){ … });
- How to
interrupt timeouts from static usage of wait()?// $.wait(timeout)… $.unwait();