resolve todos

This commit is contained in:
peterkogo
2025-04-16 18:20:12 +02:00
parent 2474c8be14
commit 97c4e2b218
7 changed files with 34 additions and 29 deletions
@@ -61,7 +61,6 @@ export default function zoom(domNode: Element, params: ZoomParams) {
onDraggingChange
});
//TODO: is this neccessary?
const viewport = panZoomInstance.getViewport();
if (
initialViewport.x !== viewport.x ||
@@ -5,8 +5,7 @@
import type { NodeProps } from '$lib/types';
let {
// TODO: do we really want this!?
data = { label: 'Node' },
data,
targetPosition = Position.Top,
sourcePosition = Position.Bottom
}: NodeProps = $props();
@@ -52,7 +52,6 @@
let labelledBy = $derived(`svelte-flow__minimap-desc-${store.flowId}`);
// TODO: simplify this
let viewBB = $derived({
x: -store.viewport.x / store.viewport.zoom,
y: -store.viewport.y / store.viewport.zoom,
@@ -11,6 +11,7 @@
} from '@xyflow/system';
import type { ResizeControlProps } from './types';
import { useSvelteFlow } from '$lib/hooks/useSvelteFlow.svelte';
import type { Node } from '$lib/types';
let {
nodeId,
@@ -67,20 +68,31 @@
};
},
onChange: (change: XYResizerChange, childChanges: XYResizerChildChange[]) => {
updateNode(id, (node) => ({
...node,
position: { x: change.x ?? node.position.x, y: change.y ?? node.position.y },
width: change.width ?? node.width,
height: change.height ?? node.height
}));
const changes = new Map<string, Partial<Node>>();
let position = change.x && change.y ? { x: change.x, y: change.y } : undefined;
changes.set(id, { ...change, position });
// TODO: performance?
for (const childChange of childChanges) {
updateNode(childChange.id, (node) => ({
...node,
changes.set(childChange.id, {
position: childChange.position
}));
});
}
store.nodes = store.nodes.map((node) => {
const change = changes.get(node.id);
if (change) {
return {
...node,
position: {
x: change.position?.x ?? node.position.x,
y: change.position?.y ?? node.position.y
},
width: change.width ?? node.width,
height: change.height ?? node.height
};
}
return node;
});
}
});
}