Skip to content
Permalink
Browse files

Add AnimationBreak event

An event that only emits when an animation is stopped before it fully finished.
  • Loading branch information
koenbok committed Nov 8, 2016
1 parent 7de77b6 commit 56a6d734937c6863ccb9fe5923b51c907d61c865
Showing with 13 additions and 1 deletion.
  1. +2 −1 framer/Animation.coffee
  2. +1 −0 framer/Events.coffee
  3. +10 −0 test/tests/LayerAnimationTest.coffee
@@ -154,6 +154,7 @@ class exports.Animation extends BaseClass

# Add the callbacks
@on(Events.AnimationStart, @options.onStart) if _.isFunction(@options.onStart)
@on(Events.AnimationBreak, @options.onBreak) if _.isFunction(@options.onBreak)
@on(Events.AnimationStop, @options.onStop) if _.isFunction(@options.onStop)
@on(Events.AnimationEnd, @options.onEnd) if _.isFunction(@options.onEnd)

@@ -192,7 +193,7 @@ class exports.Animation extends BaseClass
@_delayTimer = null

@layer.context.removeAnimation(@)

@emit(Events.AnimationBreak) if emit
@emit(Events.AnimationStop) if emit
Framer.Loop.off("update", @_update)

@@ -36,6 +36,7 @@ Events.Click = Events.TouchEnd

# Animation events
Events.AnimationStart = "start"
Events.AnimationBreak = "break"
Events.AnimationStop = "stop"
Events.AnimationEnd = "end"

@@ -698,6 +698,16 @@ describe "LayerAnimation", ->
layer.x.should.eql 0
done()

it "should call break", (done) ->
layer = new Layer
layer.animate
x: 100
options:
time: 0.1
onBreak: ->
done()
layer.animateStop()

it "should call stop", (done) ->
layer = new Layer
layer.animate

0 comments on commit 56a6d73

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