Fixed the bug 'onNodeDragStop' not getting triggered
Got rid of 'dragging' in the global node state
This commit is contained in:
+3
-7
@@ -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
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user