Permalink
Browse files

switching back current and previous being strings instead of objects

Having _previousState and _currentState as replacements

Signed-off-by: Niels van Hoorn <nvh@nvh.io>
  • Loading branch information...
nvh committed Sep 15, 2016
1 parent 0b599de commit 0970fe9b13f2bcc206e2565eadec9ac5ac7074a4
Showing with 12 additions and 10 deletions.
  1. +4 −2 framer/LayerStates.coffee
  2. +8 −8 test/tests/LayerStatesTest.coffee
@@ -36,12 +36,14 @@ deprecatedProperty = (object, name, replacementSuggestion, stateMachine, getter,
class exports.LayerStates
constructor: (stateMachine) ->
readOnlyProperty @, "previous", false, -> stateMachine.previous
readOnlyProperty @, "current", false, -> stateMachine.current
readOnlyProperty @, "default", true, -> @initial
readOnlyProperty @, "initial", false, -> stateMachine.initial
readOnlyProperty @, "previous", false, -> @previousName
readOnlyProperty @, "current", false, -> @currentName
readOnlyProperty @, "previousName", false, -> stateMachine.previousName
readOnlyProperty @, "currentName", false, -> stateMachine.currentName
readOnlyProperty @, "_previousState", false, -> stateMachine.previous
readOnlyProperty @, "_currentState", false, -> stateMachine.current
## Deprecated methods
deprecatedProperty @, "add", "layer.states = ", stateMachine, (layer) ->
@@ -17,8 +17,8 @@ describe "LayerStates", ->
test = (previous, current, states) =>
previous.should.equal initialStateName
current.should.equal 'a'
@layer.states.current.should.equal @layer.states.initial
@layer.states.currentName.should.equal initialStateName
@layer.states._currentState.should.equal @layer.states[initialStateName]
done()
@layer.on Events.StateWillSwitch, test
@@ -30,7 +30,7 @@ describe "LayerStates", ->
previous.should.equal initialStateName
current.should.equal 'a'
@layer.states.currentName.should.equal 'a'
@layer.states.current.should.equal @layer.states.a
@layer.states._currentState.should.equal @layer.states.a
done()
@layer.on Events.StateDidSwitch, test
@@ -322,15 +322,15 @@ describe "LayerStates", ->
first: x: 100, options: instant: true
second: y: 200, options: instant: true
assert.equal(layer.states.previous, null)
assert.equal(layer.states.current, layer.states.initial)
assert.equal(layer.states._previousState, null)
assert.equal(layer.states._currentState, layer.states.initial)
layer.animate 'first'
assert.equal(layer.states.previous, layer.states.initial)
layer.states.current.should.equal layer.states.first
assert.equal(layer.states._previousState, layer.states.initial)
layer.states._currentState.should.equal layer.states.first
layer.x.should.equal 100
layer.animate 'second'
assert.equal(layer.states.previous, layer.states.first)
layer.states.current.should.equal layer.states.second
assert.equal(layer.states._previousState, layer.states.first)
layer.states._currentState.should.equal layer.states.second
layer.y.should.equal 200

0 comments on commit 0970fe9

Please sign in to comment.