fix(react) fitViewOptions.nodes are now working as intended

This commit is contained in:
Peter
2023-09-25 13:46:22 +02:00
parent ada5b94673
commit 439916e619
5 changed files with 7 additions and 10 deletions
+1 -4
View File
@@ -171,7 +171,7 @@ export function fitView<Params extends FitViewParamsBase<NodeBase>, Options exte
options?: Options
) {
const filteredNodes = nodes.filter((n) => {
const isVisible = options?.includeHiddenNodes ? n.width && n.height : !n.hidden;
const isVisible = n.width && n.height && (options?.includeHiddenNodes || !n.hidden);
if (options?.nodes?.length) {
return isVisible && options?.nodes.some((optionNode) => optionNode.id === n.id);
@@ -180,11 +180,8 @@ export function fitView<Params extends FitViewParamsBase<NodeBase>, Options exte
return isVisible;
});
console.log(filteredNodes);
if (filteredNodes.length > 0) {
const bounds = getRectOfNodes(filteredNodes, nodeOrigin);
console.log(bounds);
const [x, y, zoom] = getTransformForBounds(
bounds,