Skip to content

Commit

Permalink
Fix reverse and copy for new Animation API
Browse files Browse the repository at this point in the history
  • Loading branch information
nvh committed Sep 27, 2016
1 parent 062f912 commit 038d633
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
11 changes: 4 additions & 7 deletions framer/Animation.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,8 @@ class exports.Animation extends BaseClass
reverse: ->
# TODO: Add some tests
properties = _.clone(@_originalState)
properties.options = _.clone(@options)
properties.layer = @layer
animation = new Animation properties
animation
options = _.clone(@options)
new Animation @layer, properties, options

reset: ->
for k, v of @_stateA
Expand All @@ -216,9 +214,8 @@ class exports.Animation extends BaseClass

copy: ->
properties = _.clone(@properties)
properties.options = _.clone(@options)
properties.layer = @layer
new Animation(properties)
options = _.clone(@options)
new Animation(@layer, properties, options)

# A bunch of common aliases to minimize frustration
revert: -> @reverse()
Expand Down
23 changes: 23 additions & 0 deletions test/tests/LayerAnimationTest.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,29 @@ describe "LayerAnimation", ->
Utils.delay animation.options.time, ->
done()

it "copy should work", (done) ->
layer = new Layer
x: 50
animation = new Animation layer, {x: 100}, {time: AnimationTime}
copy = animation.copy()
copy.onAnimationEnd ->
layer.x.should.equal 100
done()
copy.start()

it "reverse should work", (done) ->
layer = new Layer
x: 50
animation = new Animation layer, {x: 100}, {time: AnimationTime}
animation.onAnimationEnd ->
layer.x.should.equal 100
a = animation.reverse()
a.once Events.AnimationEnd, ->
layer.x.should.equal 50
done()
a.start()
animation.start()

describe "Context", ->

it "should list running animations", ->
Expand Down

0 comments on commit 038d633

Please sign in to comment.