Skip to content
Permalink
Browse files

Fixed animating to a single number for derived properties

  • Loading branch information
nvh committed Nov 24, 2016
1 parent 31b9b31 commit 2ddfe04d45c4d6fe38fd1389410ea5af3218638b
Showing with 22 additions and 7 deletions.
  1. +10 −7 framer/Animation.coffee
  2. +12 −0 test/tests/LayerAnimationTest.coffee
@@ -302,18 +302,21 @@ class exports.Animation extends BaseClass

# Only animate numeric properties for now
for k, v of properties
if @isAnimatable(v)
animatableProperties[k] = v
else if Color.isValidColorProperty(k, v)
animatableProperties[k] = new Color(v)
else if k in ["frame", "size", "point"] # Derived properties
if k in ["frame", "size", "point"] # Derived properties
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))

if _.isObject(v)
_.defaults(animatableProperties, _.pick(v, derivedKeys))
else if _.isNumber(v)
for derivedKey in derivedKeys
animatableProperties[derivedKey] = v
else if @isAnimatable(v)
animatableProperties[k] = v
else if Color.isValidColorProperty(k, v)
animatableProperties[k] = new Color(v)

return animatableProperties

@@ -278,6 +278,18 @@ describe "LayerAnimation", ->
layer.height.should.equal Screen.height
done()

it "should work with a single number for derived properties", (done) ->
layer = new Layer
animation = layer.animate
x: 300
size: 400

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

describe "Context", ->

it "should list running animations", ->

0 comments on commit 2ddfe04

Please sign in to comment.
You can’t perform that action at this time.