Permalink
Browse files

Getting rid of the mask pixel crack

  • Loading branch information...
nvh committed Nov 4, 2017
1 parent 7a25c71 commit f6225045b6c3b39efac43f31311c2d3a66ced609
Showing with 36 additions and 1 deletion.
  1. +10 −1 framer/Components/DeviceComponent.coffee
  2. +26 −0 test/tests/DeviceComponentTest.coffee
@@ -428,13 +428,22 @@ class exports.DeviceComponent extends BaseClass
@_hideBezel = hideBezel
if @_hideBezel
@_previousBackgroundColor = @background.backgroundColor
@background.backgroundColor = @screen.backgroundColor
if @_device.screenMask?
@background.backgroundColor = "black"
else
@background.backgroundColor = @screen.backgroundColor
@screen.on "change:backgroundColor", (color) =>
return if @_device.screenMask?
# Hacky way to keep the prev backgroundColor
prev = @_previousBackgroundColor
@background.backgroundColor = color
@_previousBackgroundColor = prev
@background.on "change:backgroundColor", (color) =>
if @_device.screenMask?
if not Color.equal(@background.backgroundColor, "black")
@_previousBackgroundColor = color
@background.backgroundColor = "black"
return
@background.backgroundColor = @screen.backgroundColor
@_previousBackgroundColor = color
else
@@ -204,3 +204,29 @@ describe "DeviceComponent", ->
Canvas.backgroundColor.toName().should.eql "green"
Framer.Device.hideBezel = false
Canvas.backgroundColor.toName().should.equal "red"
describe "when the device has a mask", ->
it "should should keep the backgroundColor black if the canvas background is set", ->
device = new DeviceComponent()
device.deviceType = "apple-iphone-x-silver"
device.context.run ->
device.background.backgroundColor = "red"
device.screen.backgroundColor = "green"
device.hideBezel = true
device.background.backgroundColor = "blue"
device.background.backgroundColor.toName().should.equal "black"
device.hideBezel = false
device.background.backgroundColor.toName().should.equal "blue"
it "should should set the backgroundColor to black", ->
device = new DeviceComponent()
device.deviceType = "apple-iphone-x-silver"
device.context.devicePixelRatio = 2
device.context.run ->
device.background.backgroundColor = "red"
device.screen.backgroundColor = "green"
device.hideBezel = true
device.background.backgroundColor.toName().should.equal "black"
device.hideBezel = false
device.background.backgroundColor.toName().should.equal "red"

0 comments on commit f622504

Please sign in to comment.