Skip to content

Commit

Permalink
Cloning states before messing with their options
Browse files Browse the repository at this point in the history
  • Loading branch information
nvh committed Oct 3, 2016
1 parent 69cc7a6 commit 8695f71
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion framer/LayerStateMachine.coffee
Expand Up @@ -39,7 +39,7 @@ class exports.LayerStateMachine extends BaseClass

# Prep the properties and the options. The options come from the state, and can be overriden
# with the function arguments here.
properties = @states[stateName]
properties = _.clone(@states[stateName])
options = _.defaults({}, options, properties.options) if properties.options

stateNameA = @currentName
Expand Down
15 changes: 15 additions & 0 deletions test/tests/LayerStatesTest.coffee
Expand Up @@ -543,6 +543,21 @@ describe "LayerStates", ->
layer.states.current.name.should.equal "default"
done()

it "should listen to animation options defined in a state", (done) ->
layer = new Layer
layer.animationOptions.time = 0.1
layer.states.testA = {x: 200, options: curve: "spring"}
cycle = layer.stateCycle onEnd: ->
layer.states.current.name.should.equal "testA"
cycle2 = layer.stateCycle onEnd: ->
layer.states.current.name.should.equal "default"
cycle3 = layer.stateCycle onEnd: ->
layer.states.current.name.should.equal "testA"
done()
cycle3.options.curve.should.equal "spring"
cycle2.options.curve.should.equal "ease"
cycle.options.curve.should.equal "spring"

describe "Switch", ->

it "should switch", ->
Expand Down

0 comments on commit 8695f71

Please sign in to comment.