diff --git a/.changeset/selfish-cooks-jump.md b/.changeset/selfish-cooks-jump.md new file mode 100644 index 00000000..0a69b6c6 --- /dev/null +++ b/.changeset/selfish-cooks-jump.md @@ -0,0 +1,5 @@ +--- +"@vue-flow/core": patch +--- + +Only emit node position changes if a position change actually occurred. diff --git a/packages/core/src/composables/useDrag.ts b/packages/core/src/composables/useDrag.ts index adda79cc..93141a3b 100644 --- a/packages/core/src/composables/useDrag.ts +++ b/packages/core/src/composables/useDrag.ts @@ -74,6 +74,7 @@ export function useDrag(params: UseDragParams) { let mousePosition: XYPosition = { x: 0, y: 0 } let dragEvent: MouseEvent | null = null let dragStarted = false + let nodePositionsChanged = false let autoPanId = 0 let autoPanStarted = false @@ -104,6 +105,8 @@ export function useDrag(params: UseDragParams) { return n }) + nodePositionsChanged = nodePositionsChanged || hasChange + if (!hasChange) { return } @@ -187,6 +190,8 @@ export function useDrag(params: UseDragParams) { return } + nodePositionsChanged = false + if (nodeDragThreshold.value === 0) { startDrag(event, nodeEl) } @@ -244,7 +249,10 @@ export function useDrag(params: UseDragParams) { } if (dragItems.length && !isClick) { - updateNodePositions(dragItems, false, false) + if (nodePositionsChanged) { + updateNodePositions(dragItems, false, false) + nodePositionsChanged = false + } const [currentNode, nodes] = getEventHandlerParams({ id,