Draggable windows now center

This commit is contained in:
Bill 2021-04-28 13:47:57 -04:00
parent 13f613ca86
commit cf372b117c

View File

@ -51,6 +51,12 @@ export function DraggableWindow(props: DraggableWindowProps): JSX.Element
bringToTop(); 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 () => return () =>
{ {
const index = currentWindows.indexOf(element); const index = currentWindows.indexOf(element);
@ -61,7 +67,7 @@ export function DraggableWindow(props: DraggableWindowProps): JSX.Element
return ( return (
<Draggable handle={ props.handle } { ...props.draggableOptions }> <Draggable handle={ props.handle } { ...props.draggableOptions }>
<div ref={ elementRef } className="position-absolute t-0 l-0 draggable-window" onMouseDownCapture={ onMouseDown }> <div ref={ elementRef } className="position-absolute draggable-window" onMouseDownCapture={ onMouseDown }>
{ props.children } { props.children }
</div> </div>
</Draggable> </Draggable>