chore(getInternalNodesBounds): cleanup

This commit is contained in:
moklick
2025-10-14 16:00:01 +02:00
parent 43e0695416
commit b5287b8808

View File

@@ -241,25 +241,17 @@ export const getInternalNodesBounds = <NodeType extends InternalNodeBase | NodeD
nodeLookup: Map<string, NodeType>,
params: GetInternalNodesBoundsParams<NodeType> = {}
): Rect => {
const emptyRect = { x: 0, y: 0, width: 0, height: 0 };
if (nodeLookup.size === 0) {
return emptyRect;
}
let box = { x: Infinity, y: Infinity, x2: -Infinity, y2: -Infinity };
let hasVisibleNodes = false;
nodeLookup.forEach((node) => {
if (params.filter === undefined || params.filter(node)) {
box = getBoundsOfBoxes(box, nodeToBox(node as InternalNodeBase));
hasVisibleNodes = true;
const nodeBox = nodeToBox(node as InternalNodeBase);
box = getBoundsOfBoxes(box, nodeBox);
}
});
return hasVisibleNodes ? boxToRect(box) : emptyRect;
return hasVisibleNodes ? boxToRect(box) : { x: 0, y: 0, width: 0, height: 0 };
};
export const getNodesInside = <NodeType extends NodeBase = NodeBase>(