refactor(svelte): selection above nodess
This commit is contained in:
@@ -94,16 +94,22 @@
|
|||||||
function onPointerDown(event: PointerEvent) {
|
function onPointerDown(event: PointerEvent) {
|
||||||
containerBounds = container?.getBoundingClientRect();
|
containerBounds = container?.getBoundingClientRect();
|
||||||
|
|
||||||
|
const isNoKeyEvent =
|
||||||
|
event.target !== container && !!(event.target as HTMLElement).closest('.nokey');
|
||||||
|
|
||||||
if (
|
if (
|
||||||
!store.elementsSelectable ||
|
!store.elementsSelectable ||
|
||||||
!isSelecting ||
|
!isSelecting ||
|
||||||
event.button !== 0 ||
|
event.button !== 0 ||
|
||||||
event.target !== container ||
|
!containerBounds ||
|
||||||
!containerBounds
|
isNoKeyEvent
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.stopPropagation();
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
(event.target as Partial<Element> | null)?.setPointerCapture?.(event.pointerId);
|
(event.target as Partial<Element> | null)?.setPointerCapture?.(event.pointerId);
|
||||||
|
|
||||||
const { x, y } = getEventPosition(event, containerBounds);
|
const { x, y } = getEventPosition(event, containerBounds);
|
||||||
@@ -216,6 +222,8 @@
|
|||||||
|
|
||||||
onpanecontextmenu?.({ event });
|
onpanecontextmenu?.({ event });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onClickCapture = (event: MouseEvent) => event.stopPropagation();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
@@ -227,10 +235,11 @@
|
|||||||
class:dragging={store.dragging}
|
class:dragging={store.dragging}
|
||||||
class:selection={isSelecting}
|
class:selection={isSelecting}
|
||||||
onclick={hasActiveSelection ? undefined : wrapHandler(onClick, container)}
|
onclick={hasActiveSelection ? undefined : wrapHandler(onClick, container)}
|
||||||
onpointerdown={hasActiveSelection ? onPointerDown : undefined}
|
onpointerdowncapture={hasActiveSelection ? onPointerDown : undefined}
|
||||||
onpointermove={hasActiveSelection ? onPointerMove : undefined}
|
onpointermove={hasActiveSelection ? onPointerMove : undefined}
|
||||||
onpointerup={hasActiveSelection ? onPointerUp : undefined}
|
onpointerup={hasActiveSelection ? onPointerUp : undefined}
|
||||||
oncontextmenu={wrapHandler(onContextMenu, container)}
|
oncontextmenu={wrapHandler(onContextMenu, container)}
|
||||||
|
onclickcapture={hasActiveSelection ? onClickCapture : undefined}
|
||||||
>
|
>
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user