feat(svelte): add snapGrid

This commit is contained in:
moklick
2023-03-14 15:43:14 +01:00
parent ae244526bd
commit 9c7bd6dc68
7 changed files with 36 additions and 16 deletions
@@ -5,7 +5,7 @@
import { Selection } from '$lib/components/Selection';
import drag from '$lib/actions/drag';
const { selectionRectMode, nodes, transform, updateNodePositions } = useStore();
const { selectionRectMode, nodes, transform, snapGrid, updateNodePositions } = useStore();
$: selectedNodes = $nodes.filter((n) => n.selected);
$: rect = getRectOfNodes(selectedNodes);
@@ -15,7 +15,7 @@
<div
class="selection-wrapper nopan"
style={`width: ${rect.width}px; height: ${rect.height}px; transform: translate(${rect.x}px, ${rect.y}px)`}
use:drag={{ nodes, transform, updateNodePositions }}
use:drag={{ nodes, snapGrid, transform, updateNodePositions }}
/>
<Selection
isVisible={$selectionRectMode === 'nodes'}