Permalink
Browse files

originTransform should be based on SVG size instead of parent size

  • Loading branch information...
nvh committed Jan 22, 2018
1 parent 7803f03 commit 97d82c5390c4392736182df611df9e1142902f79
Showing with 7 additions and 3 deletions.
  1. +7 −3 framer/SVGBaseLayer.coffee
View
@@ -35,9 +35,9 @@ originTransform = (value, layer, name) ->
when "originY" then sizeProp = "height"
return value unless sizeProp?
layerSize = layer[sizeProp]
parentSize = layer.parent[sizeProp]
return value unless layerSize >= 0 and parentSize > 0
return (layerSize / parentSize) * value
svgSize = layer._svgSize[sizeProp]
return value unless layerSize >= 0 and svgSize > 0
return (layerSize / svgSize) * value
class exports.SVGBaseLayer extends Layer
# Overridden Layer properties
@@ -117,6 +117,10 @@ class exports.SVGBaseLayer extends Layer
@_stylesAppliedToParent = ["webkitTransform", "webkitTransformOrigin"]
for prop in ["x", "y", "z", "scaleX", "scaleY", "scaleZ", "scale", "skewX", "skewY", "skew", "rotationX", "rotationY", "rotationZ", "force2d", "originX", "originY"]
options[prop] ?= @_parent[prop]
svgLayer = @_parent
while svgLayer? and not (svgLayer instanceof SVGLayer)
svgLayer = svgLayer.parent
@_svgSize = svgLayer.size
pathProperties = ["fill", "stroke", "stroke-width", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke-dasharray", "stroke-dashoffset", "name", "opacity"]
_.defaults options, @constructor.attributesFromElement(pathProperties, element)

0 comments on commit 97d82c5

Please sign in to comment.