Skip to content
Permalink
Browse files

Better fix for clearing background color when setting iamge/gradient.

  • Loading branch information
Jonas Treub
Jonas Treub committed Jun 28, 2017
1 parent 5b4c3bc commit 0d40d081ae19912fdc6b18c3f8f80d855c4626a3
Showing with 8 additions and 7 deletions.
  1. +8 −7 framer/Layer.coffee
@@ -887,25 +887,26 @@ class exports.Layer extends BaseClass
set: (value) ->

currentValue = @_getPropertyValue "image"

if currentValue is value
return @emit "load"

# Unset the background color only if it’s the default color
defaults = Defaults.getDefaults "Layer", {}
if @backgroundColor?.isEqual(defaults.backgroundColor)
@backgroundColor = null
isBackgroundColorDefault = @backgroundColor?.isEqual(defaults.backgroundColor)

if LinearGradient.isLinearGradient(value)
@emit("change:gradient", value, currentValue)
@emit("change:image", value, currentValue)
@_setPropertyValue("image", value)
@style["background-image"] = value.toCSS()
@backgroundColor = null if isBackgroundColorDefault
return

if not (_.isString(value) or value is null)
layerValueTypeError("image", value)

if currentValue is value
return @emit "load"

# Unset the background color only if it’s the default color
@backgroundColor = null if isBackgroundColorDefault

# Set the property value
@_setPropertyValue("image", value)
if value in [null, ""]

0 comments on commit 0d40d08

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