Permalink
Browse files

Added animateToState

  • Loading branch information...
nvh committed Jul 26, 2016
1 parent 5b8ca53 commit b0b408e26dbb0c8f24b43645622a400b5d513006
Showing with 11 additions and 7 deletions.
  1. +11 −7 framer/Layer.coffee
View
@@ -890,16 +890,20 @@ class exports.Layer extends BaseClass
delete options.properties
@animateTo(properties, options)
animateToState: (stateName, options={}) ->
properties = @_stateMachine.switchTo stateName
finished = options.completion
options.completion = =>
# If we changed the state, we send the event that we did
if @_stateMachine.previousName isnt stateName
@_stateMachine.emit(Events.StateDidSwitch, @_stateMachine.previousName, @_stateMachine.currentName, @)
finished?()
@animateTo properties, options
animateTo: (properties,options={}) ->
if typeof properties == 'string'
stateName = properties
properties = @states[stateName]
if not properties?
throw Error "No such state: '#{stateName}'"
#Switch the state
@states.emit(Events.StateWillSwitch, @states.currentName, stateName, @)
@states._previousStates.push(@states.currentName)
@states._currentName = stateName
return @animateToState stateName, options
_.defaults(options,properties.options)
delete properties.options

0 comments on commit b0b408e

Please sign in to comment.