Permalink
Browse files

rename options in state object to animationOptions

  • Loading branch information...
nvh committed Oct 6, 2016
1 parent 1f18a6c commit 6e5b9324cbd52b4eebdc7e8306a2100d99f9e96e
Showing with 12 additions and 8 deletions.
  1. +4 −3 framer/LayerStateMachine.coffee
  2. +8 −5 test/tests/LayerStatesTest.coffee
@@ -40,14 +40,15 @@ 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 = _.clone(@states[stateName])
options = _.defaults({}, options, properties.options) if properties.options
options = _.defaults({}, options, properties.animationOptions) if properties.animationOptions
delete properties.animationOptions
stateNameA = @currentName
stateNameB = stateName
# Note: even if the state is the current state we still want to switch because some properties
# 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
@@ -63,7 +64,7 @@ class exports.LayerStateMachine extends BaseClass
onEnd = =>
instantProperties = _.difference(
_.keys(properties),
_.keys(properties),
_.keys(animation.properties))
for k in instantProperties
@@ -361,9 +361,9 @@ describe "LayerStates", ->
# assert.equal(layerB.parent, layerA)
it "should set the current and previous states when switching", ->
layer = new Layer
layer.states =
stateA: {x: 100, options: instant: true}
stateB: {y: 200, options: instant: true}
@@ -460,7 +460,7 @@ describe "LayerStates", ->
layer = new Layer
layer.animationOptions.time = 0.1
layer.states.test = {x: 200}
layer.on Events.StateSwitchEnd, ->
layer.states.current.name.should.equal "test"
done()
@@ -570,10 +570,10 @@ describe "LayerStates", ->
layer.states.current.name.should.equal "default"
done()
it "should listen to animation options defined in a state", (done) ->
it "should listen to animationOptions defined in a state", (done) ->
layer = new Layer
layer.animationOptions.time = 0.1
layer.states.testA = {x: 200, options: curve: "spring"}
layer.states.testA = {x: 200, animationOptions: curve: "spring"}
cycle = layer.stateCycle onEnd: ->
layer.states.current.name.should.equal "testA"
cycle2 = layer.stateCycle onEnd: ->
@@ -582,8 +582,11 @@ describe "LayerStates", ->
layer.states.current.name.should.equal "testA"
done()
cycle3.options.curve.should.equal "spring"
layer.animationOptions.should.eql {time: 0.1}
cycle2.options.curve.should.equal "ease"
layer.animationOptions.should.eql {time: 0.1}
cycle.options.curve.should.equal "spring"
layer.animationOptions.should.eql {time: 0.1}
describe "Switch", ->

0 comments on commit 6e5b932

Please sign in to comment.