Permalink
Browse files

Making animating to Screen or other objects with more properties not …

…crash
  • Loading branch information...
nvh committed Nov 23, 2016
1 parent b6fbac8 commit 31b9b31d77000b97ca8a8602997a3504f2188201
Showing with 18 additions and 1 deletion.
  1. +6 −1 framer/Animation.coffee
  2. +12 −0 test/tests/LayerAnimationTest.coffee
View
@@ -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
@@ -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", ->

0 comments on commit 31b9b31

Please sign in to comment.