added correct expandParent offset of children

This commit is contained in:
peterkogo
2024-04-15 17:23:14 +02:00
parent ccf6578824
commit 87086e9997
5 changed files with 34 additions and 8 deletions
@@ -67,7 +67,7 @@ function ResizeControl({
};
},
onChange: (change: XYResizerChange, childChanges: XYResizerChildChange[]) => {
const { triggerNodeChanges, nodeLookup } = store.getState();
const { triggerNodeChanges, nodeLookup, parentLookup } = store.getState();
const changes: NodeChange[] = [];
const newPosition = { x: change.x, y: change.y };
@@ -86,7 +86,7 @@ function ResizeControl({
const nodeWith = evaluateNodePosition(nodeWithChange, nodeLookup) as InternalNodeWithParentExpand;
const parentExpandChanges = handleParentExpand([nodeWith], nodeLookup);
const parentExpandChanges = handleParentExpand([nodeWith], nodeLookup, parentLookup);
changes.push(...parentExpandChanges);
newPosition.x = change.x ? Math.max(0, change.x) : undefined;
newPosition.y = change.y ? Math.max(0, change.y) : undefined;
+10 -3
View File
@@ -76,6 +76,7 @@ const createRFStore = ({
onNodesChange,
fitView,
nodeLookup,
parentLookup,
fitViewOnInit,
fitViewDone,
fitViewOnInitOptions,
@@ -84,7 +85,13 @@ const createRFStore = ({
debug,
} = get();
const { changes, updatedInternals } = updateNodeInternalsSystem(updates, nodeLookup, domNode, nodeOrigin);
const { changes, updatedInternals } = updateNodeInternalsSystem(
updates,
nodeLookup,
parentLookup,
domNode,
nodeOrigin
);
if (!updatedInternals) {
return;
@@ -116,7 +123,7 @@ const createRFStore = ({
}
},
updateNodePositions: (nodeDragItems, dragging = false) => {
const { nodeLookup } = get();
const { nodeLookup, parentLookup } = get();
type ExpandParentInternalNode = InternalNode & { parentId: string; expandParent: true };
const expandParentNodes: ExpandParentInternalNode[] = [];
@@ -148,7 +155,7 @@ const createRFStore = ({
});
if (expandParentNodes.length > 0) {
const parentExpandChanges = handleParentExpand(expandParentNodes, nodeLookup);
const parentExpandChanges = handleParentExpand(expandParentNodes, nodeLookup, parentLookup);
changes.push(...parentExpandChanges);
}