Permalink
Browse files

Trying to prevent pixel cracks with a screen background instead of ch…

…anging color
  • Loading branch information...
nvh committed Nov 7, 2017
1 parent 56878c5 commit 87660fa7ff0735aec8a1c9ebfc423628f9acfb78
Showing with 7 additions and 27 deletions.
  1. +5 −25 framer/Components/DeviceComponent.coffee
  2. +2 −2 test/tests/DeviceComponentTest.coffee
@@ -94,6 +94,8 @@ class exports.DeviceComponent extends BaseClass
@hands = new Layer name: "hands"
@handsImageLayer = new Layer parent: @hands, name: "handsImage"
@phone = new Layer parent: @hands, name: "phone"
# This background is made slightly bigger than the screen to prevent the background shining through cracks
@screenBackground = new Layer parent: @hands, name: "screenBackground", backgroundColor: "black"
@screen = new Layer parent: @hands, name: "phone"
@viewport = new Layer parent: @screen, name: "screen"
@content = new Layer parent: @viewport, name: "viewport"
@@ -188,7 +190,10 @@ class exports.DeviceComponent extends BaseClass
screenSizeChanged = @content.width isnt width or @content.height isnt height
@content.width = width
@content.height = height
@screenBackground.width = @screen.width + 40
@screenBackground.height = @screen.height + 40
@setHand(@selectedHand) if @selectedHand and @_orientation is 0
centerLayer(@screenBackground)
centerLayer(@screen)
centerLayer(@screenMask)
@@ -426,31 +431,6 @@ class exports.DeviceComponent extends BaseClass
set: (hideBezel) ->
return if not Utils.isFramerStudio()
@_hideBezel = hideBezel
if @_hideBezel
@_previousBackgroundColor = @background.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
@screen.off "change:backgroundColor"
@background.off "change:backgroundColor"
if @_previousBackgroundColor?
@background.backgroundColor = @_previousBackgroundColor
@_update()
@@ -174,7 +174,7 @@ describe "DeviceComponent", ->
# Exceptions
assert(key in ["fullscreen", "custom", "sony-w85Oc", "test"], "#{key} should have a platform specified")
describe "when not showing bezel", ->
describe.skip "when not showing bezel", ->
before ->
Utils.isFramerStudio = ->
return true
@@ -196,7 +196,7 @@ describe "DeviceComponent", ->
Framer.Device.hideBezel = false
Canvas.backgroundColor.toName().should.equal "blue"
describe "when showing bezel", ->
describe.skip "when showing bezel", ->
it "should revert to the background color before disabling the bezel", ->
Canvas.backgroundColor = "red"
Framer.Device.screen.backgroundColor = "green"

0 comments on commit 87660fa

Please sign in to comment.