refactor(node-changes): add dragging flag closes #2171

This commit is contained in:
moklick
2022-05-26 18:40:39 +02:00
parent 101f5d25d0
commit b6eb0acb30
6 changed files with 30 additions and 17 deletions
+9 -6
View File
@@ -89,19 +89,22 @@ const createStore = () =>
onNodesChange?.(changes);
}
},
updateNodePositions: (nodeDragItems: NodeDragItem[]) => {
updateNodePositions: (nodeDragItems: NodeDragItem[], positionChanged = true, dragging = false) => {
const { onNodesChange, nodeInternals, hasDefaultNodes } = get();
if (hasDefaultNodes || onNodesChange) {
const changes: NodePositionChange[] = [];
nodeDragItems.forEach((node) => {
const changes = nodeDragItems.map((node) => {
const change: NodePositionChange = {
id: node.id,
type: 'position',
position: node.position,
dragging,
};
changes.push(change);
if (positionChanged) {
change.position = node.position;
}
return change;
});
if (changes?.length) {