Merge pull request #5615 from xyflow/fix/svelte-node-resizer

Fix/svelte node resizer
This commit is contained in:
Moritz Klack
2025-11-11 20:01:37 +01:00
committed by GitHub
2 changed files with 11 additions and 9 deletions

View File

@@ -0,0 +1,5 @@
---
'@xyflow/svelte': patch
---
Fix wrong positions when resizing nodes with a non-default node-origin

View File

@@ -68,14 +68,11 @@
},
onChange: (change: XYResizerChange, childChanges: XYResizerChildChange[]) => {
// eslint-disable-next-line svelte/prefer-svelte-reactivity
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 });
const changes = new Map<string, XYResizerChange>();
changes.set(id, change);
for (const childChange of childChanges) {
changes.set(childChange.id, {
position: childChange.position
});
changes.set(childChange.id, {x: childChange.position.x, y: childChange.position.y });
}
store.nodes = store.nodes.map((node) => {
@@ -84,11 +81,11 @@
const vertical = !resizeDirection || resizeDirection === 'vertical';
if (change) {
return {
return {
...node,
position: {
x: horizontal ? (change.position?.x ?? node.position.x) : node.position.x,
y: vertical ? (change.position?.y ?? node.position.y) : node.position.y
x: horizontal ? (change.x ?? node.position.x) : node.position.x,
y: vertical ? (change.y ?? node.position.y) : node.position.y
},
width: horizontal ? (change.width ?? node.width) : node.width,
height: vertical ? (change.height ?? node.height) : node.height