Merge pull request #30 from mStirner/animation-stop
added stop method to animation
This commit is contained in:
commit
01f4eb2ff1
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