Permalink
Browse files

Cancel delay when animation is stopped

Fixes #398
  • Loading branch information...
nvh committed Aug 3, 2016
1 parent 2cb1e4a commit db95db366da701be1b429e06319dbfd013243894
Showing with 21 additions and 2 deletions.
  1. +4 −2 framer/Animation.coffee
  2. +17 −0 test/tests/LayerAnimationTest.coffee
View
@@ -150,13 +150,15 @@ class exports.Animation extends BaseClass
# If we have a delay, we wait a bit for it to start
if @options.delay
Utils.delay(@options.delay, start)
@_delayTimer = Utils.delay(@options.delay, start)
else
start()
return true
stop: (emit=true)->
if @_delayTimer?
Framer.CurrentContext.removeTimer(@_delayTimer)
@_delayTimer = null
@options.layer.context.removeAnimation(@)
@emit("stop") if emit
@@ -320,6 +320,23 @@ describe "LayerAnimation", ->
layer.x.should.be.within(30, 50)
done()
it "should stop when stopped before delay ends", (done) ->
layer = new Layer()
animation = new Animation
layer: layer
properties: {x:50}
curve: "linear"
time: 0.5
delay: 0.3
animation.start()
animation.stop()
Utils.delay 0.3, ->
layer.x.should.equal 0
Utils.delay 0.5, ->
layer.x.should.equal 0
done()
describe "Repeat", ->
it "should start repeatedly", (done) ->

0 comments on commit db95db3

Please sign in to comment.