fix intersections for svelte flow
This commit is contained in:
@@ -13,12 +13,14 @@
|
||||
const { getIntersectingNodes } = useSvelteFlow();
|
||||
|
||||
function onNodeDrag({ detail: { targetNode } }) {
|
||||
const intersections = getIntersectingNodes(targetNode).map((n) => n.id);
|
||||
if (targetNode) {
|
||||
const intersections = getIntersectingNodes(targetNode).map((n) => n.id);
|
||||
|
||||
$nodes.forEach((n) => {
|
||||
n.class = intersections.includes(n.id) ? 'highlight' : '';
|
||||
});
|
||||
$nodes = $nodes;
|
||||
$nodes.forEach((n) => {
|
||||
n.class = intersections.includes(n.id) ? 'highlight' : '';
|
||||
});
|
||||
$nodes = $nodes;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -10,7 +10,8 @@ export const initialNodes: Node[] = [
|
||||
{
|
||||
id: '2',
|
||||
data: { label: 'Node 2' },
|
||||
position: { x: 0, y: 150 }
|
||||
position: { x: 0, y: 150 },
|
||||
parentId: '1'
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
|
||||
Reference in New Issue
Block a user