From f17d88053cf0bdae68298f4b898fc8424d3d0728 Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Thu, 14 Jun 2018 06:48:03 -0700 Subject: [PATCH] Ensure we don't render off screen if we are in a hidden iframe when we load --- js/components/WindowManager.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/components/WindowManager.js b/js/components/WindowManager.js index 5eb1db5b..a0b16fbc 100644 --- a/js/components/WindowManager.js +++ b/js/components/WindowManager.js @@ -63,11 +63,13 @@ class WindowManager extends React.Component { const windowPositions = {}; const keys = this.windowKeys(); const totalHeight = keys.length * WINDOW_HEIGHT; + const globalOffsetLeft = Math.max(0, width / 2 - WINDOW_WIDTH / 2); + const globalOffsetTop = Math.max(0, height / 2 - totalHeight / 2); keys.forEach((key, i) => { const offset = WINDOW_HEIGHT * i; windowPositions[key] = { - x: Math.ceil(offsetLeft + (width / 2 - WINDOW_WIDTH / 2)), - y: Math.ceil(offsetTop + (height / 2 - totalHeight / 2 + offset)) + x: Math.ceil(offsetLeft + globalOffsetLeft), + y: Math.ceil(offsetTop + (globalOffsetTop + offset)) }; }); this.props.updateWindowPositions(windowPositions);