Skip to content
Permalink
Browse files

Fix for ease-in, ease-out etc.

  • Loading branch information...
koenbok committed Oct 5, 2014
1 parent fbde7a8 commit 0a61fc4b861c9566724e543eb6fd190d0352cdef
Showing with 13 additions and 4 deletions.
  1. +13 −2 framer/Animation.coffee
  2. +0 −2 framer/Animators/BezierCurveAnimator.coffee
@@ -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')

@@ -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
@@ -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

@@ -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],

0 comments on commit 0a61fc4

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