Created
January 15, 2013 07:14
-
-
Save drhayes/4536848 to your computer and use it in GitHub Desktop.
EventChain's repeat method
This file contains 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
update.repeat = function(times) { | |
times = times || Infinity; | |
var originalTimes = times; | |
var stepsCopy; | |
steps.push(function() { | |
times -= 1; | |
if (times > 0) { | |
var args = stepsCopy.slice(0); | |
args.unshift(1, 0); | |
[].splice.apply(steps, args); | |
} else { | |
// For successive repeats. | |
times = originalTimes; | |
} | |
// End. | |
steps.shift(); | |
}); | |
stepsCopy = steps.slice(0); | |
return this; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment