Permalink
Browse files

Cloning states before messing with their options

  • Loading branch information...
nvh committed Oct 3, 2016
1 parent 69cc7a6 commit 8695f71b06db3925574aa607d40b3da24b532a80
Showing with 16 additions and 1 deletion.
  1. +1 −1 framer/LayerStateMachine.coffee
  2. +15 −0 test/tests/LayerStatesTest.coffee
@@ -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
@@ -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", ->

0 comments on commit 8695f71

Please sign in to comment.