Skip to content

Commit

Permalink
Fix finish() when called on animation with delay
Browse files Browse the repository at this point in the history
  • Loading branch information
nvh committed Oct 7, 2016
1 parent bed29aa commit 9f8be26
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 5 additions & 5 deletions framer/Animation.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,11 @@ class exports.Animation extends BaseClass
@restart()
if not @looping
@_repeatCounter--

# Figure out what kind of values we have so we don't have to do it in
# the actual update loop. This saves a lot of frame budget.
@_prepareUpdateValues()

# If animate is false we set everything immediately and skip the actual animation
start = @_start

Expand Down Expand Up @@ -222,7 +227,6 @@ class exports.Animation extends BaseClass

_instant: =>
@emit(Events.AnimationStart)
@_prepareUpdateValues()
@_updateValues(1)
@emit(Events.AnimationStop)
@emit(Events.AnimationEnd)
Expand All @@ -239,10 +243,6 @@ class exports.Animation extends BaseClass
@emit(Events.AnimationStart)
Framer.Loop.on("update", @_update)

# Figure out what kind of values we have so we don't have to do it in
# the actual update loop. This saves a lot of frame budget.
@_prepareUpdateValues()

finish: =>
@stop()
@_updateValues(1)
Expand Down
8 changes: 7 additions & 1 deletion test/tests/LayerAnimationTest.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,13 @@ describe "LayerAnimation", ->
x: 50
animation2.isNoop.should.be.equal true


it "In shouldn't crash when finish on delayed animation", ->
layer = new Layer
animation = layer.animate
x: 50
options:
delay: 1
animation.finish.should.not.throw()

describe "Context", ->

Expand Down

0 comments on commit 9f8be26

Please sign in to comment.