mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-01-31 10:22:36 +01:00
Fix draggables
This commit is contained in:
parent
1f562d01b1
commit
1378417904
@ -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>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user