Skip to content

Commit

Permalink
Make curve function work with Framer.Defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
nvh committed Feb 17, 2017
1 parent 6d8bc7e commit 9d08997
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion framer/Defaults.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ exports.Defaults =
defaults = _.cloneDeep Originals[className]
# Copy over the user defined options
for k, v of Framer.Defaults[className]
defaults[k] = if _.isFunction(v) then v() else v
# Make an exception for curve functions
if _.isFunction(v) and not (className is "Animation" and k is "curve")
defaults[k] = v()
else
defaults[k] = v

# Then copy over the default keys to the options
for k, v of defaults
Expand Down
14 changes: 14 additions & 0 deletions test/tests/LayerAnimationTest.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ describe "LayerAnimation", ->

Framer.resetDefaults()

it "should handle default spring curves correctly", ->

Framer.Defaults.Animation =
curve: Spring(0.5)

layer = new Layer
animation = layer.animate
x: 50

animation._animator.constructor.name.should.equal "SpringRK4Animator"

Framer.resetDefaults()


it "should use linear", ->

# We shouldn't change the linear default, people rely on it
Expand Down

0 comments on commit 9d08997

Please sign in to comment.