fixed, parentExpand & simplified updateNodePositions

This commit is contained in:
peterkogo
2024-01-24 13:44:28 +01:00
parent 5d3efa73a8
commit 829c82cfda
5 changed files with 9 additions and 15 deletions
+3 -6
View File
@@ -151,19 +151,16 @@ const createRFStore = ({
onNodesChange?.(changes);
}
},
updateNodePositions: (nodeDragItems, positionChanged = true, dragging = false) => {
updateNodePositions: (nodeDragItems, dragging = false) => {
const changes = nodeDragItems.map((node) => {
const change: NodePositionChange = {
id: node.id,
type: 'position',
position: node.position,
positionAbsolute: node.computed?.positionAbsolute,
dragging,
};
if (positionChanged) {
change.positionAbsolute = node.computed?.positionAbsolute;
change.position = node.position;
}
return change;
});
+2 -1
View File
@@ -3,6 +3,7 @@ import { EdgeLookup, NodeLookup } from '@xyflow/system';
import type { Node, Edge, EdgeChange, NodeChange, NodeSelectionChange, EdgeSelectionChange } from '../types';
export function handleParentExpand(updatedElements: any[], updateItem: any) {
console.log(updatedElements, updateItem);
for (const [index, item] of updatedElements.entries()) {
if (item.id === updateItem.parentNode) {
const parent = { ...item };
@@ -106,7 +107,7 @@ function applyChanges(changes: any[], elements: any[]): any[] {
const updatedElement = { ...element };
for (const change of changes) {
applyChange(change, updatedElement, elements);
applyChange(change, updatedElement, updatedElements);
}
updatedElements.push(updatedElement);