Skip to content

Instantly share code, notes, and snippets.

@gciampa
Created January 27, 2010 03:49
Show Gist options
  • Select an option

  • Save gciampa/287522 to your computer and use it in GitHub Desktop.

Select an option

Save gciampa/287522 to your computer and use it in GitHub Desktop.
jQuery.slowEach = function(array, interval, callback) {
if(!array.length) return;
var i = 0;
next();
function next() {
if(callback.call(array[i], i, array[i]) !== false)
if(++i < array.length)
setTimeout(next, interval);
}
return array;
};
jQuery.fn.slowEach = function(interval, callback) {
return jQuery.slowEach(this, interval, callback);
};
// sample usage
$(document).ready(function() {
$('.reveal').slowEach(500, function() {
$(this).show();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment