Permalink
Browse files

Added stylesAppliedToParent instead of parentAlias

  • Loading branch information...
nvh committed Jan 19, 2018
1 parent 55a881b commit ee99adf0fb97fd3252d93d5e48e2336675c9df84
Showing with 9 additions and 23 deletions.
  1. +7 −2 framer/Layer.coffee
  2. +2 −21 framer/SVGBaseLayer.coffee
View
@@ -52,9 +52,12 @@ layerProperty = (obj, name, cssProperty, fallback, validator, transformer, optio
@_properties[name] = value
mainElement = @_element if includeMainElement or not targetElement
subElement = @[targetElement] if targetElement?
if cssProperty isnt null
elementContainer = @
if cssProperty in @_stylesAppliedToParent
elementContainer = @parent
mainElement = elementContainer._element if includeMainElement or not targetElement
subElement = elementContainer[targetElement] if targetElement?
if name is cssProperty and not LayerStyle[cssProperty]?
mainElement?.style[cssProperty] = @_properties[name]
subElement?.style[cssProperty] = @_properties[name]
@@ -159,6 +162,8 @@ class exports.Layer extends BaseClass
@_style = {}
@_children = []
@_stylesAppliedToParent ?= []
# Special power setting for 2d rendering path. Only enable this
# if you know what you are doing. See LayerStyle for more info.
@_prefer2d = false
View
@@ -24,27 +24,6 @@ class exports.SVGBaseLayer extends Layer
@_parent or null
@define "html", get: -> @_element.outerHTML or ""
@parentAlias = (name, defaultValue = 0) ->
originalDescriptor = Object.getOwnPropertyDescriptor(Layer::, name)
@define name,
default: defaultValue
get: ->
if @_parent instanceof SVGLayer
return @_parent[name]
else
return originalDescriptor.get.call(@)
set: (value) ->
if @_parent instanceof SVGLayer
if @__applyingDefaults
@_properties[name] = value
else
@_parent[name] = value
else
originalDescriptor.set?.call(@, value)
@parentAlias "x"
@parentAlias "y"
@parentAlias "z"
@define "width", get: -> @_width
@define "height", get: -> @_height
@@ -134,6 +113,8 @@ class exports.SVGBaseLayer extends Layer
@_element.transform.baseVal.removeItem(index)
@calculateSize()
if @_parent instanceof SVGLayer
@_stylesAppliedToParent = ["webkitTransform"]
super(options)

0 comments on commit ee99adf

Please sign in to comment.