Permalink
Browse files

Add inside and outside aliases for shadow type

  • Loading branch information...
nvh committed Sep 13, 2017
1 parent adda6dd commit 70e360636605822000f242affda34b452a1b127c
Showing with 36 additions and 4 deletions.
  1. +11 −4 framer/LayerStyle.coffee
  2. +25 −0 test/tests/LayerTest.coffee
View
@@ -45,13 +45,20 @@ getShadowStrings = (layer, types, createString) ->
result = []
if layer.shadows?
for shadow in layer.shadows
if shadow is null or not (shadow.type in types)
if shadow is null
continue
shadow = _.defaults _.clone(shadow), Framer.Defaults.Shadow
if shadow.x is 0 and shadow.y is 0 and shadow.blur is 0 and shadow.spread is 0
if shadow.type is "inside"
shadow.type = "inset"
else if shadow.type is "outside"
if layer.image? and layer.image isnt ""
shadow.type = "drop"
else
shadow.type = "box"
if not (shadow.type in types) or (shadow.x is 0 and shadow.y is 0 and shadow.blur is 0 and shadow.spread is 0)
continue
dropShadow = createString(shadow, layer.context.pixelMultiplier)
result.push(dropShadow)
shadowString = createString(shadow, layer.context.pixelMultiplier)
result.push(shadowString)
return result
exports.LayerStyle =
@@ -932,6 +932,31 @@ describe "Layer", ->
l.style.textShadow.should.equal "rgba(123, 123, 123, 0.498039) 5px 0px 0px"
l.style.webkitFilter.should.equal "drop-shadow(rgba(123, 123, 123, 0.498039) 0px 15px 0px)"
it "should use outside as an alias for box shadow", ->
l = new Layer
l.shadow1 =
type: "outside"
x: 10
l.shadow1.type.should.equal "outside"
l.style.boxShadow.should.equal "rgba(123, 123, 123, 0.498039) 10px 0px 0px 0px"
it "should use outside as an alias for drop shadow when image is set", ->
l = new Layer
image: "static/test2.png"
l.shadow1 =
type: "outside"
x: 10
l.shadow1.type.should.equal "outside"
l.style.webkitFilter.should.equal "drop-shadow(rgba(123, 123, 123, 0.498039) 10px 0px 0px)"
it "should use inside as an alias for inset shadow", ->
l = new Layer
l.shadow1 =
type: "inside"
x: 10
l.shadow1.type.should.equal "inside"
l.style.boxShadow.should.equal "rgba(123, 123, 123, 0.498039) 10px 0px 0px 0px inset"
describe "Events", ->
it "should remove all events", ->

0 comments on commit 70e3606

Please sign in to comment.