Permalink
Browse files

Only set the image if the gradient is valid.

Also allow setting the gradient using an object, but only via the gradient property.
  • Loading branch information...
eelco authored and jonastreub committed Jun 20, 2017
1 parent 6d4efa6 commit 7aacaa865efff6a4f6802978ea2522836b773845
Showing with 9 additions and 1 deletion.
  1. +6 −1 framer/Layer.coffee
  2. +3 −0 framer/LinearGradient.coffee
View
@@ -960,7 +960,12 @@ class exports.Layer extends BaseClass
return @image if LinearGradient.isLinearGradient(@image)
return null
set: (value) ->
@image = value
if LinearGradient.isLinearGradient(value)
@image = value
else
gradientOptions = LinearGradient._asPlainObject(value)
if not _.isEmpty(gradientOptions)
@image = new LinearGradient(gradientOptions)
##############################################################
## HIERARCHY
@@ -74,3 +74,6 @@ class exports.LinearGradient extends BaseClass
equalStart = Color.equal(gradientA.start, gradientB.start)
equalEnd = Color.equal(gradientA.end, gradientB.end)
return equalAngle and equalStart and equalEnd
@_asPlainObject: (gradient) ->
_.pick(gradient, ["start", "end", "angle"])

0 comments on commit 7aacaa8

Please sign in to comment.