Skip to content

Commit

Permalink
Make state animation listen to options.start
Browse files Browse the repository at this point in the history
  • Loading branch information
nvh committed Oct 3, 2016
1 parent 32000eb commit a9c5455
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions framer/LayerStateMachine.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class exports.LayerStateMachine extends BaseClass
# might be different as they could be set by hand on the layer object.

# Grab the animation and make state switching have the same events (start, stop, end)
startAnimation = options.start ? true
options.start = false
animation = @layer.animate(properties, options)

Expand All @@ -73,8 +74,8 @@ class exports.LayerStateMachine extends BaseClass
animation.on(Events.AnimationStart, onStart)
animation.on(Events.AnimationStop, onStop)
animation.on(Events.AnimationEnd, onEnd)
animation.start()

animation.start() if startAnimation

return animation

Expand Down
8 changes: 8 additions & 0 deletions test/tests/LayerStatesTest.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,14 @@ describe "LayerStates", ->
animation = layer.animate "test", time: 4
animation.options.time.should.equal 4

it "should listen to layer.animate options.start", ->
layer = new Layer
layer.states.test = {x: 100}
animation = layer.animate "test", start: false
animation.isAnimating.should.equal false
animation.start()
animation.isAnimating.should.equal true

describe "Callbacks", ->

it "should call start", (done) ->
Expand Down

0 comments on commit a9c5455

Please sign in to comment.