Fixed the bug 'onNodeDragStop' not getting triggered

Got rid of 'dragging' in the global node state
This commit is contained in:
Furkan Kalaycioglu
2022-04-27 20:37:59 +03:00
parent 73118c356c
commit f075e0742e
11 changed files with 41 additions and 75 deletions
+3 -7
View File
@@ -96,7 +96,7 @@ const createStore = () =>
onNodesChange?.(changes);
}
},
updateNodePosition: ({ id, diff, dragging }: NodeDiffUpdate) => {
updateNodePosition: ({ id, diff }: NodeDiffUpdate) => {
const { onNodesChange, nodeExtent, nodeInternals, hasDefaultNodes, snapGrid, snapToGrid } = get();
if (hasDefaultNodes || onNodesChange) {
@@ -105,14 +105,10 @@ const createStore = () =>
nodeInternals.forEach((node) => {
if (node.selected) {
if (!node.parentNode || !isParentSelected(node, nodeInternals)) {
changes.push(
createPositionChange({ node, diff, dragging, nodeExtent, nodeInternals, snapToGrid, snapGrid })
);
changes.push(createPositionChange({ node, diff, nodeExtent, nodeInternals, snapToGrid, snapGrid }));
}
} else if (node.id === id) {
changes.push(
createPositionChange({ node, diff, dragging, nodeExtent, nodeInternals, snapToGrid, snapGrid })
);
changes.push(createPositionChange({ node, diff, nodeExtent, nodeInternals, snapToGrid, snapGrid }));
}
});
+1 -4
View File
@@ -44,7 +44,7 @@ export function createNodeInternals(nodes: Node[], nodeInternals: NodeInternals)
const parentNodes: ParentNodes = {};
nodes.forEach((node) => {
const z = isNumeric(node.zIndex) ? node.zIndex : node.dragging || node.selected ? 1000 : 0;
const z = isNumeric(node.zIndex) ? node.zIndex : node.selected ? 1000 : 0;
const internals: Node = {
...nodeInternals.get(node.id),
@@ -112,7 +112,6 @@ type CreatePostionChangeParams = {
nodeExtent: CoordinateExtent;
nodeInternals: NodeInternals;
diff?: XYPosition;
dragging?: boolean;
snapToGrid?: boolean;
snapGrid?: SnapGrid;
};
@@ -120,7 +119,6 @@ type CreatePostionChangeParams = {
export function createPositionChange({
node,
diff,
dragging,
nodeExtent,
nodeInternals,
snapToGrid,
@@ -129,7 +127,6 @@ export function createPositionChange({
const change: NodePositionChange = {
id: node.id,
type: 'position',
dragging: !!dragging,
};
if (diff) {