From cf372b117ce4dc9b2b52169283df5e9835c3734b Mon Sep 17 00:00:00 2001 From: Bill Date: Wed, 28 Apr 2021 13:47:57 -0400 Subject: [PATCH] Draggable windows now center --- src/hooks/draggable-window/DraggableWindow.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hooks/draggable-window/DraggableWindow.tsx b/src/hooks/draggable-window/DraggableWindow.tsx index 403af1bc..19484805 100644 --- a/src/hooks/draggable-window/DraggableWindow.tsx +++ b/src/hooks/draggable-window/DraggableWindow.tsx @@ -51,6 +51,12 @@ export function DraggableWindow(props: DraggableWindowProps): JSX.Element bringToTop(); + const left = ((document.body.clientWidth - element.clientWidth) / 2); + const top = ((document.body.clientHeight - element.clientHeight) / 2); + + element.style.left = `${ left }px`; + element.style.top = `${ top }px`; + return () => { const index = currentWindows.indexOf(element); @@ -61,7 +67,7 @@ export function DraggableWindow(props: DraggableWindowProps): JSX.Element return ( -
+
{ props.children }