Permalink
Browse files

Make image property compatible with gradients and add gradient shorth…

…and property
  • Loading branch information...
jonastreub committed Jun 12, 2017
1 parent 3fb7b5d commit 289e98ba04744ea35acb6967b28db910e72babed
Showing with 16 additions and 0 deletions.
  1. +16 −0 framer/Layer.coffee
View
@@ -8,6 +8,7 @@ Utils = require "./Utils"
{BaseClass} = require "./BaseClass"
{EventEmitter} = require "./EventEmitter"
{Color} = require "./Color"
{LinearGradient} = require "./LinearGradient"
{Matrix} = require "./Matrix"
{Animation} = require "./Animation"
{LayerStyle} = require "./LayerStyle"
@@ -885,6 +886,14 @@ class exports.Layer extends BaseClass
@_getPropertyValue "image"
set: (value) ->
if LinearGradient.isLinearGradient(value)
oldValue = @_getPropertyValue "image"
@emit("change:gradient", value, oldValue)
@emit("change:image", value, oldValue)
@_setPropertyValue("image", value)
@style["background-image"] = value.toCSS()
return
if not (_.isString(value) or value is null)
layerValueTypeError("image", value)
@@ -947,6 +956,13 @@ class exports.Layer extends BaseClass
else
@style["background-image"] = "url('#{imageUrl}')"
@define "gradient",
get: ->
return @image if LinearGradient.isLinearGradient(@image)
return null
set: (value) ->
@image = value
##############################################################
## HIERARCHY

0 comments on commit 289e98b

Please sign in to comment.