Skip to content

Commit

Permalink
Making animating to Screen or other objects with more properties not …
Browse files Browse the repository at this point in the history
…crash
  • Loading branch information
nvh committed Nov 23, 2016
1 parent b6fbac8 commit 31b9b31
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
7 changes: 6 additions & 1 deletion framer/Animation.coffee
Expand Up @@ -307,7 +307,12 @@ class exports.Animation extends BaseClass
else if Color.isValidColorProperty(k, v)
animatableProperties[k] = new Color(v)
else if k in ["frame", "size", "point"] # Derived properties
_.defaults(animatableProperties, v)
switch k
when "frame" then derivedKeys = ["x", "y", "width", "height"]
when "size" then derivedKeys = ["width", "height"]
when "point" then derivedKeys = ["x", "y"]
else derivedKeys = []
_.defaults(animatableProperties, _.pick(v, derivedKeys))


return animatableProperties
Expand Down
12 changes: 12 additions & 0 deletions test/tests/LayerAnimationTest.coffee
Expand Up @@ -266,6 +266,18 @@ describe "LayerAnimation", ->
layer.height.should.equal 500
done()

it "should work with using objects that have more properties", (done) ->
layer = new Layer
animation = layer.animate
x: 300
size: Screen

animation.onAnimationEnd ->
layer.x.should.equal 300
layer.width.should.equal Screen.width
layer.height.should.equal Screen.height
done()

describe "Context", ->

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

0 comments on commit 31b9b31

Please sign in to comment.