diff --git a/packages/system/src/xydrag/XYDrag.ts b/packages/system/src/xydrag/XYDrag.ts index 33658aad..42a399da 100644 --- a/packages/system/src/xydrag/XYDrag.ts +++ b/packages/system/src/xydrag/XYDrag.ts @@ -104,6 +104,7 @@ export function XYDrag voi let dragStarted = false; let d3Selection: Selection | null = null; let abortDrag = false; // prevents unintentional dragging on multitouch + let nodePositionsChanged = false; // public functions function update({ @@ -191,6 +192,8 @@ export function XYDrag voi dragItem.internals.positionAbsolute = positionAbsolute; } + nodePositionsChanged = nodePositionsChanged || hasChange; + if (!hasChange) { return; } @@ -294,6 +297,7 @@ export function XYDrag voi containerBounds = domNode?.getBoundingClientRect() || null; abortDrag = false; + nodePositionsChanged = false; if (nodeDragThreshold === 0) { startDrag(event); @@ -354,7 +358,10 @@ export function XYDrag voi if (dragItems.size > 0) { const { nodeLookup, updateNodePositions, onNodeDragStop, onSelectionDragStop } = getStoreItems(); - updateNodePositions(dragItems, false); + if (nodePositionsChanged) { + updateNodePositions(dragItems, false); + nodePositionsChanged = false; + } if (onDragStop || onNodeDragStop || (!nodeId && onSelectionDragStop)) { const [currentNode, currentNodes] = getEventHandlerParams({