refactor(react/internal-nodes): cleanup

This commit is contained in:
moklick
2024-04-03 12:54:55 +02:00
parent 6753c19188
commit f45f50671d
2 changed files with 31 additions and 22 deletions
+12 -2
View File
@@ -136,8 +136,18 @@ const createRFStore = ({
dragging,
};
if (internalNode?.expandParent) {
triggerChangeNodes.push(internalNode);
if (internalNode?.expandParent && change.position) {
triggerChangeNodes.push({
...internalNode,
position: change.position,
internals: {
...internalNode.internals,
positionAbsolute: node.internals.positionAbsolute,
},
});
change.position.x = Math.max(0, change.position.x);
change.position.y = Math.max(0, change.position.y);
}
return change;
+19 -20
View File
@@ -91,28 +91,27 @@ export function adoptUserProvidedNodes<NodeType extends NodeBase>(
parentNodeIds.add(n.parentNode);
}
if (n === currentStoreNode?.internals?.userProvidedNode) {
if (n === currentStoreNode?.internals.userProvidedNode) {
nodeLookup.set(n.id, currentStoreNode);
return currentStoreNode;
} else {
const node: InternalNodeBase<NodeType> = {
...options.defaults,
...n,
computed: {
width: n.computed?.width,
height: n.computed?.height,
},
internals: {
positionAbsolute: n.position,
handleBounds: currentStoreNode?.internals?.handleBounds,
z: (isNumeric(n.zIndex) ? n.zIndex : 0) + (n.selected ? selectedNodeZ : 0),
userProvidedNode: n,
isParent: false,
},
};
nodeLookup.set(node.id, node);
}
const node: InternalNodeBase<NodeType> = {
...options.defaults,
...n,
computed: {
width: n.computed?.width,
height: n.computed?.height,
},
internals: {
positionAbsolute: n.position,
handleBounds: currentStoreNode?.internals?.handleBounds,
z: (isNumeric(n.zIndex) ? n.zIndex : 0) + (n.selected ? selectedNodeZ : 0),
userProvidedNode: n,
isParent: false,
},
};
nodeLookup.set(node.id, node);
});
if (parentNodeIds.size > 0) {