From 593109e8c52298c7ad34b4f587bf668a2a19187e Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Sat, 18 Aug 2018 10:02:40 -0700 Subject: [PATCH] Improve centering within given node --- js/components/WindowManager.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/components/WindowManager.js b/js/components/WindowManager.js index 367d38f6..5a3cf397 100644 --- a/js/components/WindowManager.js +++ b/js/components/WindowManager.js @@ -31,8 +31,9 @@ class WindowManager extends React.Component { centerWindows = () => { const { container } = this.props; - const offsetLeft = container.offsetLeft; - const offsetTop = container.offsetTop; + const rect = container.getBoundingClientRect(); + const offsetLeft = rect.left + window.scrollX; + const offsetTop = rect.top + window.scrollY; const width = container.scrollWidth; const height = container.scrollHeight;