Skip to content

Instantly share code, notes, and snippets.

@DannyDelott
Last active August 29, 2015 14:16
Show Gist options
  • Save DannyDelott/684b47a7b5d458a8134b to your computer and use it in GitHub Desktop.
Save DannyDelott/684b47a7b5d458a8134b to your computer and use it in GitHub Desktop.
betterInterval Example
$(function(){
$content.on('click', function(){
// case 1: currently playing, let's stop it
if(!changeQuote.stop){
$content.css('background', '#ddd');
changeQuote.stop = true;
}
// case 2: we've stopped it, but we're waiting for a response
else if(!changeQuote.stopped && changeQuote.stop) {
changeQuote.stop = false;
$content.css('background', '#eee');
changeQuote();
}
// case 3: restart the interval
else {
$content.css('background', '#eee');
betterInterval(changeQuote, 5000, true);
}
});
betterInterval(changeQuote, 5000, true);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment