-
-
Save adriancmiranda/628fa5f02cf138d9e96e64dc6a5bf325 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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