refactor(store): use getNodes function

This commit is contained in:
moklick
2022-12-08 18:13:35 +01:00
parent 7c51a61f10
commit c51ae89eeb
18 changed files with 61 additions and 58 deletions
+2 -4
View File
@@ -120,7 +120,7 @@ type InternalFitViewOptions = {
export function fitView(get: StoreApi<ReactFlowState>['getState'], options: InternalFitViewOptions = {}) {
const {
nodeInternals,
getNodes,
width,
height,
minZoom,
@@ -134,9 +134,7 @@ export function fitView(get: StoreApi<ReactFlowState>['getState'], options: Inte
if ((options.initial && !fitViewOnInitDone && fitViewOnInit) || !options.initial) {
if (d3Zoom && d3Selection) {
const nodes = Array.from(nodeInternals.values()).filter((n) =>
options.includeHiddenNodes ? n.width && n.height : !n.hidden
);
const nodes = getNodes().filter((n) => (options.includeHiddenNodes ? n.width && n.height : !n.hidden));
const nodesInitialized = nodes.every((n) => n.width && n.height);