Fix draggables

This commit is contained in:
Bill 2021-04-23 01:16:09 -04:00
parent 1f562d01b1
commit 1378417904

View File

@ -22,6 +22,22 @@ export function DraggableWindow(props: DraggableWindowProps): JSX.Element
function onMouseDown(event: MouseEvent): void function onMouseDown(event: MouseEvent): void
{ {
const index = currentWindows.indexOf(elementRef.current);
if(index === -1)
{
currentWindows.push(elementRef.current);
}
else if(index === (currentWindows.length - 1)) return;
else if(index >= 0)
{
currentWindows.splice(index, 1);
currentWindows.push(elementRef.current);
}
bringToTop(); bringToTop();
} }
@ -43,7 +59,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" onMouseDown={ onMouseDown }> <div ref={ elementRef } className="position-absolute t-0 l-0" onMouseDownCapture={ onMouseDown }>
{ props.children } { props.children }
</div> </div>
</Draggable> </Draggable>