Skip to content

Commit

Permalink
fix manually positioned nodes jumping around
Browse files Browse the repository at this point in the history
  • Loading branch information
fechan committed May 27, 2024
1 parent acb4106 commit 1ca54d5
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions client/src/GraphUpdateCallbacks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,6 @@ function onNodeDragStop(
clearDropTarget();
} else if (draggedNode.type === "machine" || draggedNode.type === "group") {
// update node x/y
const mousePosition = reactFlowInstance.screenToFlowPosition({
x: mouseEvent.clientX,
y: mouseEvent.clientY,
});

let nodeEditReq: MachineEditReq | GroupEditReq;
if (draggedNode.type === "machine") {
Expand All @@ -176,8 +172,8 @@ function onNodeDragStop(
reqId: uuidv4(),
machineId: draggedNode.id,
edits: {
x: mousePosition.x,
y: mousePosition.y,
x: draggedNode.position.x,
y: draggedNode.position.y,
}
};
} else if (draggedNode.type === "group") {
Expand All @@ -187,8 +183,8 @@ function onNodeDragStop(
reqId: uuidv4(),
groupId: draggedNode.id,
edits: {
x: parentPos.x - mousePosition.x,
y: parentPos.y - mousePosition.y,
x: parentPos.x - draggedNode.position.x,
y: parentPos.y - draggedNode.position.y,
}
}
}
Expand Down

0 comments on commit 1ca54d5

Please sign in to comment.