Skip to content

Instantly share code, notes, and snippets.

@positlabs
Created December 19, 2013 22:36
Show Gist options
  • Save positlabs/8047427 to your computer and use it in GitHub Desktop.
Save positlabs/8047427 to your computer and use it in GitHub Desktop.
define(function (require, exports, module) {
/**
*
* simple stagger function
*
* TODO: add option for a timing function... will require changing @arg interval to duration
*
* */
return function (targets, interval, action, delay) {
function fire() {
for (var i = 0, maxi = targets.length; i < maxi; i++) {
(function () {
var target = targets[i];
setTimeout(function () {
action(target);
}, interval * i);
})();
}
}
if (delay !== undefined && delay > 0) setTimeout(fire, delay);
else fire();
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment