Permalink
Browse files

Added rotationAtFraction and ofsetted angle animation with start

  • Loading branch information...
nvh committed Feb 1, 2018
1 parent e1711bd commit 8cc82e704c3bf83774d807d4695ea933cfab405f
Showing with 11 additions and 4 deletions.
  1. +11 −4 framer/SVGPath.coffee
View
@@ -108,6 +108,15 @@ class exports.SVGPath extends SVGBaseLayer
pointAtFraction: (fraction) ->
@_path.getPointAtLength(@length * fraction)
rotationAtFraction: (fraction, delta = 0.01) ->
if delta <= 0
delta = 0.01
fromPoint = @pointAtFraction(Math.max(fraction - delta, 0))
toPoint = @pointAtFraction(Math.min(fraction + delta, 1))
angle = Math.atan2(fromPoint.y - toPoint.y, fromPoint.x - toPoint.x) * 180 / Math.PI - 90
return angle
convertStartToLayer: (layer) ->
@convertPointToLayer(@start, layer)
@@ -125,9 +134,7 @@ class exports.SVGPath extends SVGBaseLayer
return (key, value) =>
target[key] = offset + @pointAtFraction(value).y
when "angle"
offset -= @rotationAtFraction(0)
return (key, value, delta = 0) =>
return if delta is 0
fromPoint = @pointAtFraction(Math.max(value - delta, 0))
toPoint = @pointAtFraction(Math.min(value + delta, 1))
angle = Math.atan2(fromPoint.y - toPoint.y, fromPoint.x - toPoint.x) * 180 / Math.PI - 90
target[key] = angle
target[key] = offset + @rotationAtFraction(value, delta)

0 comments on commit 8cc82e7

Please sign in to comment.