Reworked edge rerendering
This commit is contained in:
@@ -93,7 +93,6 @@ export function adoptUserNodes<NodeType extends NodeBase>(
|
||||
nodeLookup.clear();
|
||||
parentLookup.clear();
|
||||
|
||||
const updatedChildNodes = new Set<string>();
|
||||
for (const userNode of nodes) {
|
||||
let internalNode = tmpLookup.get(userNode.id);
|
||||
|
||||
@@ -124,10 +123,9 @@ export function adoptUserNodes<NodeType extends NodeBase>(
|
||||
}
|
||||
|
||||
if (userNode.parentId) {
|
||||
updateChildNode(internalNode, nodeLookup, parentLookup, options, updatedChildNodes);
|
||||
updateChildNode(internalNode, nodeLookup, parentLookup, options);
|
||||
}
|
||||
}
|
||||
return updatedChildNodes;
|
||||
}
|
||||
|
||||
function updateParentLookup<NodeType extends NodeBase>(
|
||||
@@ -154,8 +152,7 @@ function updateChildNode<NodeType extends NodeBase>(
|
||||
node: InternalNodeBase<NodeType>,
|
||||
nodeLookup: NodeLookup<InternalNodeBase<NodeType>>,
|
||||
parentLookup: ParentLookup<InternalNodeBase<NodeType>>,
|
||||
options?: UpdateNodesOptions<NodeType>,
|
||||
updatedChildNodes?: Set<string>
|
||||
options?: UpdateNodesOptions<NodeType>
|
||||
) {
|
||||
const { elevateNodesOnSelect, nodeOrigin, nodeExtent } = mergeObjects(defaultOptions, options);
|
||||
const parentId = node.parentId!;
|
||||
@@ -176,12 +173,15 @@ function updateChildNode<NodeType extends NodeBase>(
|
||||
const positionChanged = x !== positionAbsolute.x || y !== positionAbsolute.y;
|
||||
|
||||
if (positionChanged || z !== node.internals.z) {
|
||||
node.internals = {
|
||||
...node.internals,
|
||||
positionAbsolute: positionChanged ? { x, y } : positionAbsolute,
|
||||
z,
|
||||
};
|
||||
updatedChildNodes?.add(node.id);
|
||||
// we create a new object to mark the node as updated
|
||||
nodeLookup.set(node.id, {
|
||||
...node,
|
||||
internals: {
|
||||
...node.internals,
|
||||
positionAbsolute: positionChanged ? { x, y } : positionAbsolute,
|
||||
z,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user