Skip to content

Instantly share code, notes, and snippets.

@BBB
Created February 1, 2010 15:33
Show Gist options
  • Save BBB/291749 to your computer and use it in GitHub Desktop.
Save BBB/291749 to your computer and use it in GitHub Desktop.
var timer;
var sections = [] // array of sections, could just be a jQuery selector
var i = 0;
var cycle = function (sections, i) {
if (i < sections.length) {
timer = setTimeout(function () {
//animate section
cycle(i+=1, sections)
}, 3000)
} else { // start again
cycle(0, sections);
}
}
cycle(0 , sections);
$('.bubble').click(function () {
clearTimeout(timer);
//animate section
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment