feat(svelte): selection box

This commit is contained in:
moklick
2023-02-20 19:01:43 +01:00
parent fe84a5d21a
commit 1f44bc4da5
17 changed files with 501 additions and 154 deletions
@@ -0,0 +1,23 @@
<script lang="ts">
import { getRectOfNodes } from '@reactflow/utils';
import { useStore } from '$lib/store';
import Selection from '$lib/components/Selection/index.svelte';
const { selectionRectModeStore, nodesStore, nodeOriginStore } = useStore();
$: selectedNodes = $nodesStore.filter(n => n.selected);
$: rect = getRectOfNodes(selectedNodes, $nodeOriginStore);
// @todo: use zoom action for selection
</script>
{#if selectedNodes}
<Selection
isVisible={$selectionRectModeStore === 'nodes'}
width={rect.width}
height={rect.height}
x={rect.x}
y={rect.y}
/>
{/if}