added stop method to animation
This commit is contained in:
parent
a8ad19cb67
commit
f558e0465a
1 changed files with 10 additions and 2 deletions
12
anim.js
12
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
|
||||
module.exports = Anim
|
||||
|
|
Loading…
Reference in a new issue