Hey guys,Quick question : Is there a way to say
"if layer is in this state do thiselse do that"
One way to do this would be to couple any interaction where you switch states with anything else you'd like to do. For example:
On click -> Switch to StateA and Fade BackgroundWhen switched to StateA -> Show Background
On click of other button -> Switch to StateB and Fade Background again, etc.
These events may be useful to you:Events.StateWillSwitch Events.StateDidSwitchEvents.AnimationEnd
thanks Benjamin, could you help me writing this down in Coffeescript ?
Hey William, sure! This is a small example:
imageLayer.on Events.Click, -> imageLayer.states.switch("second")
imageLayer.on Events.AnimationEnd, -> backgroundLayer.animate properties: opacity:0 time:0.5
So on click of the layer, we switch states and when the state has been switched [the animation played] we animate the backgroundlayer
very cool, thanks :)
Note that everything within the functions (->) is indented with a tab :)
and here's an example of willswitch. didswitch works similarly.
imageLayer.states.on Events.StateWillSwitch, (oldState, newState) -> if oldState is "second" print "switching from second to third"
William Hutter check this CodePen for the answer: http://codepen.io/akolchenko/pen/vJdtx