refactor(fitview-nodes): cleanup

This commit is contained in:
moklick
2023-02-13 12:42:22 +01:00
parent 16114d2e56
commit a501f9a643
4 changed files with 32 additions and 37 deletions
+3 -4
View File
@@ -143,14 +143,13 @@ export function fitView(get: StoreApi<ReactFlowState>['getState'], options: Inte
if (d3initialized && (isInitialFitView || !options.initial)) {
const nodes = getNodes().filter((n) => {
const isVisible = (options.includeHiddenNodes ? n.width && n.height : !n.hidden);
let shouldInclude = true;
const isVisible = options.includeHiddenNodes ? n.width && n.height : !n.hidden;
if (options.nodes?.length) {
shouldInclude = options.nodes.includes(n.id);
return isVisible && options.nodes.some((optionNode) => optionNode.id === n.id);
}
return isVisible && shouldInclude;
return isVisible;
});
const nodesInitialized = nodes.every((n) => n.width && n.height);
+1 -1
View File
@@ -76,7 +76,7 @@ export type FitViewOptions = {
minZoom?: number;
maxZoom?: number;
duration?: number;
nodes?: string[];
nodes?: (Partial<Node> & { id: Node['id'] })[];
};
export type OnConnectStartParams = {