Skip to content
Permalink
Browse files

Remove emitting of events from animation noop

Still fire them when switching states, though
  • Loading branch information
nvh committed Oct 11, 2016
1 parent a8d00eb commit 8753f2aee5ef218276a0d6d6de3b5bd11e32b193
Showing with 14 additions and 5 deletions.
  1. +5 −3 framer/Animation.coffee
  2. +8 −2 framer/LayerStateMachine.coffee
  3. +1 −0 test/tests/LayerAnimationTest.coffee
@@ -235,9 +235,11 @@ class exports.Animation extends BaseClass

_noop: =>
@isNoop = true
@emit(Events.AnimationStart)
@emit(Events.AnimationStop)
@emit(Events.AnimationEnd)
# We don't emit these so you can call layer.animate safely
# from the same layers layer.onAnimationEnd handler
# @emit(Events.AnimationStart)
# @emit(Events.AnimationStop)
# @emit(Events.AnimationEnd)
return not @isNoop

_start: =>
@@ -80,14 +80,20 @@ class exports.LayerStateMachine extends BaseClass

for k in instantProperties
@layer[k] = properties[k]

@emit(Events.StateSwitchEnd, stateNameA, stateNameB, @)

animation.on(Events.AnimationStart, onStart)
animation.on(Events.AnimationStop, onStop)
animation.on(Events.AnimationEnd, onEnd)

animation.start() if startAnimation
if startAnimation
started = animation.start()
if not started
# When the animation didn't even start, the animation events will not be emitted,
# so call the handlers manually
onStart()
onStop()
onEnd()

switchState()

@@ -673,6 +673,7 @@ describe "LayerAnimation", ->
curve: "spring"
time: 2
instant: true
start: false

calledEvents = []

0 comments on commit 8753f2a

Please sign in to comment.
You can’t perform that action at this time.