Permalink
Browse files

Fix reverse and copy for new Animation API

  • Loading branch information...
nvh committed Sep 27, 2016
1 parent 062f912 commit 038d63315f918f521c29fda383424f23cf8d3830
Showing with 27 additions and 7 deletions.
  1. +4 −7 framer/Animation.coffee
  2. +23 −0 test/tests/LayerAnimationTest.coffee
@@ -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
@@ -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()
@@ -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", ->

0 comments on commit 038d633

Please sign in to comment.