Permalink
Browse files

Improving performance by not setting webkit* styles multiple times du…

…ring applyDefaults
  • Loading branch information...
nvh committed Sep 5, 2017
1 parent fa5ddfa commit 242f61de0a0ccdedb8a0e4f9eeaeb3708d2aa0b2
Showing with 9 additions and 2 deletions.
  1. +9 −2 framer/Layer.coffee
View
@@ -54,12 +54,13 @@ layerProperty = (obj, name, cssProperty, fallback, validator, transformer, optio
mainElement = @_element if includeMainElement or not targetElement
subElement = @[targetElement] if targetElement?
if cssProperty isnt null
if name is cssProperty and not LayerStyle[cssProperty]?
mainElement?.style[cssProperty] = @_properties[name]
subElement?.style[cssProperty] = @_properties[name]
else
else if not @__applyingDefaults
# These values are set multiple times during applyDefaults, so ignore them here, and set the style in the constructor
or (cssProperty not in ["webkitTransform", "webkitFilter", "webkitPerspectiveOrigin", "webkitTransformOrigin"])
style = LayerStyle[cssProperty](@)
mainElement?.style[cssProperty] = style
subElement?.style[cssProperty] = style
@@ -203,7 +204,13 @@ class exports.Layer extends BaseClass
options.parent = options.superLayer
delete options.superLayer
@__applyingDefaults = true
super Defaults.getDefaults("Layer", options)
delete @__applyingDefaults
@_element.style["webkitTransform"] = LayerStyle["webkitTransform"](@)
@_element.style["webkitFilter"] = LayerStyle["webkitFilter"](@)
@_element.style["webkitTransformOrigin"] = LayerStyle["webkitTransformOrigin"](@)
@_element.style["webkitPerspectiveOrigin"] = LayerStyle["webkitPerspectiveOrigin"](@)
# Add this layer to the current context
@_context.addLayer(@)

0 comments on commit 242f61d

Please sign in to comment.