Skip to content

Instantly share code, notes, and snippets.

@devcem
Created September 13, 2014 21:23
Show Gist options
  • Save devcem/955d6cdbe465f550a9e2 to your computer and use it in GitHub Desktop.
Save devcem/955d6cdbe465f550a9e2 to your computer and use it in GitHub Desktop.
Javascript sequence
/*
You can use it for animations or sequential processes.
*/
function sequence(){
var length = arguments.length-1;
var delay = arguments[length];
for(i=0;i<length;i++){
setTimeout(
(function(s) {
return function() {
s();
}
})(arguments[i]), delay*i);
}
}
sequence(
function(){alert("First alert")},
function(){alert("Second alert after 2 second")},
function(){alert("And more...")},
1000
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment