diff --git a/anim.js b/anim.js index 614fff3..e4ebff3 100644 --- a/anim.js +++ b/anim.js @@ -5,6 +5,7 @@ var resolution = 25 function Anim() { this.fx_stack = [] + this.interval = null } Anim.prototype.add = function(to, duration, options) { @@ -19,6 +20,13 @@ Anim.prototype.delay = function(duration) { return this.add({}, duration) } +Anim.prototype.stop = function () { + if(this.interval) { + clearInterval(this.interval) + } + this.fx_stack = [] +} + Anim.prototype.run = function(universe, onFinish) { var config = {} var t = 0 @@ -56,7 +64,7 @@ Anim.prototype.run = function(universe, onFinish) { } ani_setup() - var iid = setInterval(ani_step, resolution) + var iid = this.interval = setInterval(ani_step, resolution) } -module.exports = Anim \ No newline at end of file +module.exports = Anim