Skip to content

Commit

Permalink
Fix for ease-in, ease-out etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
koenbok committed Oct 5, 2014
1 parent fbde7a8 commit 0a61fc4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
15 changes: 13 additions & 2 deletions framer/Animation.coffee
Expand Up @@ -21,6 +21,8 @@ AnimatorClasses =
AnimatorClasses["spring"] = AnimatorClasses["spring-rk4"]
AnimatorClasses["cubic-bezier"] = AnimatorClasses["bezier-curve"]

AnimatorClassBezierPresets = ["ease", "ease-in", "ease-out", "ease-in-out"]

numberRE = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/
relativePropertyRE = new RegExp('^(?:([+-])=|)(' + numberRE.source + ')([a-z%]*)$', 'i')

Expand Down Expand Up @@ -202,18 +204,22 @@ class exports.Animation extends EventEmitter

_animatorClass: ->

parsedCurve = Utils.parseFunction @options.curve
parsedCurve = Utils.parseFunction(@options.curve)
animatorClassName = parsedCurve.name.toLowerCase()

if AnimatorClasses.hasOwnProperty animatorClassName
if AnimatorClasses.hasOwnProperty(animatorClassName)
return AnimatorClasses[animatorClassName]

if animatorClassName in AnimatorClassBezierPresets
return BezierCurveAnimator

return LinearAnimator

_parseAnimatorOptions: ->

animatorClass = @_animatorClass()
parsedCurve = Utils.parseFunction @options.curve
animatorClassName = parsedCurve.name.toLowerCase()

# This is for compatibility with the direct Animation.time argument. This should
# ideally also be passed as a curveOption
Expand All @@ -225,6 +231,11 @@ class exports.Animation extends EventEmitter

@options.curveOptions.time ?= @options.time

# Support ease-in etc
if animatorClass in [BezierCurveAnimator] and animatorClassName in AnimatorClassBezierPresets
@options.curveOptions.values = animatorClassName
@options.curveOptions.time ?= @options.time

# All this is to support curve: "spring(100,20,10)". In the future we'd like people
# to start using curveOptions: {tension:100, friction:10} etc

Expand Down
2 changes: 0 additions & 2 deletions framer/Animators/BezierCurveAnimator.coffee
Expand Up @@ -31,8 +31,6 @@ class exports.BezierCurveAnimator extends Animator
time: 1
precision: 1/1000

console.log "values", @options.values

@_unitBezier = new UnitBezier \
@options.values[0],
@options.values[1],
Expand Down

0 comments on commit 0a61fc4

Please sign in to comment.