Permalink
Browse files

Merge pull request #433 from nvh/feature/remove-undocument-deprecated…

…-api

Feature/remove undocument deprecated api
  • Loading branch information...
nvh committed Oct 11, 2016
2 parents 61c5401 + 3806d50 commit a8d00eba5490bf7a866cffd912f46393d4bba29a
@@ -36,6 +36,9 @@ class exports.LayerStateMachine extends BaseClass
# Check if the state exists, if not this is a pretty serious error
throw Error "No such state: '#{stateName}'" unless @states[stateName]
if stateName == "previous"
stateName = @previousName
# 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])
View
@@ -101,53 +101,16 @@ class LayerStates
deprecatedWarning("switchInstant", "layer.animate(\"state\", {instant: true})")
@machine.switchTo(stateName, {instant: true})
state: ->
deprecatedWarning("state", "layer.states.current.name")
@machine.currentName
all: ->
deprecatedWarning("all", "layer.stateNames")
@machine.stateNames
stateNames: ->
deprecatedWarning("stateNames", "layer.stateNames")
@machine.stateNames
states: ->
deprecatedWarning("states", "layer.stateNames")
@machine.stateNames
animatingKeys: ->
deprecatedWarning("animatingKeys")
keys = []
for name, state of @
keys = _.union(keys, _.keys(state))
return keys
next: (options...) ->
deprecatedWarning("next", "layer.stateCycle()")
options = _.flatten(options)
@machine.layer.stateCycle(options)
last: (options) ->
deprecatedWarning("last")
@machine.switchTo(@machine.previousName, options)
on: (eventName, handler) ->
@machine.on(eventName, handler)
@defineReserved "add", get: -> methods.add
@defineReserved "remove", get: -> methods.remove
@defineReserved "switch", get: -> methods.switch
@defineReserved "switchInstant", get: -> methods.switchInstant
@defineReserved "animatingKeys", get: -> methods.animatingKeys
@defineReserved "next", get: -> methods.next
@defineReserved "last", get: -> methods.last
@defineReserved "state", get: methods.state
@defineReserved "all", get: methods.all
@defineReserved "stateNames", get: methods.stateNames
@defineReserved "states", get: methods.states
@defineReserved "on", get: -> methods.on
@defineReserved "animationOptions",
get: -> @machine.layer.animationOptions
set: (options) -> @machine.layer.animationOptions = options
@@ -10,24 +10,24 @@ describe "LayerStates Backwards compatibility", ->
layer.states.add
stateA: x: 200
stateB: scale: 0.5
assert.deepEqual layer.states.stateNames, [initialStateName, "stateA", "stateB"]
assert.deepEqual layer.stateNames, [initialStateName, "stateA", "stateB"]
assert.deepEqual layer.states.stateA, x: 200
assert.deepEqual layer.states.stateB, scale: 0.5
it "should still support layer.states.add single", ->
layer = new Layer
layer.states.add("stateA", x: 200)
assert.deepEqual layer.states.stateNames, [initialStateName, "stateA"]
assert.deepEqual layer.stateNames, [initialStateName, "stateA"]
assert.deepEqual layer.states.stateA, x: 200
it "should still support layer.states.remove", ->
layer = new Layer
layer.states =
stateA: x: 200
stateB: scale: 0.5
assert.deepEqual layer.states.stateNames, [initialStateName, "stateA", "stateB"]
assert.deepEqual layer.stateNames, [initialStateName, "stateA", "stateB"]
layer.states.remove "stateA"
assert.deepEqual layer.states.stateNames, [initialStateName, "stateB"]
assert.deepEqual layer.stateNames, [initialStateName, "stateB"]
it "should still support layer.states.switch", (done) ->
layer = new Layer
@@ -47,29 +47,6 @@ describe "LayerStates Backwards compatibility", ->
layer.states.switchInstant "stateB"
assert.equal layer.states.current.name, "stateB"
it "should still support layer.states.all", ->
layer = new Layer
layer.states =
stateA: x: 200
stateB: scale: 0.5
assert.deepEqual layer.states.all, [initialStateName, "stateA", "stateB"]
it "should still support layer.states.states", ->
layer = new Layer
layer.states =
stateA: x: 200
stateB: scale: 0.5
assert.deepEqual layer.states.states, [initialStateName, "stateA", "stateB"]
it "should still support layer.states.animatingKeys", ->
layer = new Layer
layer.states =
stateA: x: 200, y: 300
stateB: scale: 0.5
assert.deepEqual layer.states.animatingKeys().sort(), ["width", "height", "visible", "opacity", "clip", "scrollHorizontal", "scrollVertical", "x", "y", "z", "scaleX", "scaleY", "scaleZ", "scale", "skewX", "skewY", "skew", "originX", "originY", "originZ", "perspective", "perspectiveOriginX", "perspectiveOriginY", "rotationX", "rotationY", "rotationZ", "rotation", "blur", "brightness", "saturate", "hueRotate", "contrast", "invert", "grayscale", "sepia", "shadowX", "shadowY", "shadowBlur", "shadowSpread", "shadowColor", "backgroundColor", "color", "borderColor", "borderWidth", "force2d", "flat", "backfaceVisible", "borderRadius", "html", "image", "scrollX", "scrollY", "mouseWheelSpeedMultiplier", "velocityThreshold", "constrained"].sort()
# delete layer.states[initialStateName]
# assert.deepEqual layer.states.animatingKeys().sort(), ["x", "y", "scale"].sort()
it "should still support layer.states.next", (done) ->
layer = new Layer
layer.states =
@@ -106,19 +83,6 @@ describe "LayerStates Backwards compatibility", ->
layer.states.next ["stateB", "stateA"]
layer.states.next ["stateB", "stateA"]
it "should still support layer.states.last", (done) ->
layer = new Layer
layer.states =
stateA: x: 200
stateB: scale: 0.5
layer.stateSwitch "stateB"
layer.stateSwitch "stateA"
layer.stateSwitch "stateB"
layer.onStateDidSwitch ->
assert.equal layer.states.current.name, "stateA"
done()
layer.states.last()
it "should still support layer.states.animationOptions", ->
layer = new Layer
layer.states =
@@ -168,21 +132,21 @@ describe "LayerStates Backwards compatibility", ->
test = (previous, current, states) =>
previous.should.equal "default"
current.should.equal "a"
@layer.states.state.should.equal "default"
@layer.states.current.name.should.equal "default"
done()
@layer.states.on Events.StateWillSwitch, test
@layer.on Events.StateWillSwitch, test
@layer.states.switchInstant "a"
it "should emit didSwitch when switching", (done) ->
test = (previous, current, states) =>
previous.should.equal "default"
current.should.equal "a"
@layer.states.state.should.equal "a"
@layer.states.current.name.should.equal "a"
done()
@layer.states.on Events.StateDidSwitch, test
@layer.on Events.StateDidSwitch, test
@layer.states.switchInstant "a"
@@ -215,6 +215,19 @@ describe "LayerStates", ->
done()
animation = layer.animate "stateA", time: 0.05
it "should change the state name when using 'previous' as stateName", (done) ->
layer = new Layer
layer.states =
stateA: x: 200
stateB: scale: 0.5
layer.stateSwitch "stateB"
layer.stateSwitch "stateA"
layer.stateSwitch "stateB"
layer.onStateDidSwitch ->
assert.equal layer.states.current.name, "stateA"
done()
layer.animate "previous"
describe "Properties", ->
it "should bring back the 'initial' state values when using 'stateCycle'", (done) ->

0 comments on commit a8d00eb

Please sign in to comment.