From 78d6b3d53772a97a7bb935575ace770e0dfefd93 Mon Sep 17 00:00:00 2001 From: peterkogo Date: Mon, 12 Aug 2024 16:04:43 +0200 Subject: [PATCH] fix(onlyRenderVisible) render nodes with fixed width & height intially --- packages/system/src/utils/graph.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/system/src/utils/graph.ts b/packages/system/src/utils/graph.ts index 62c3d9da..207799bc 100644 --- a/packages/system/src/utils/graph.ts +++ b/packages/system/src/utils/graph.ts @@ -191,21 +191,22 @@ export const getNodesInside = ( const visibleNodes: InternalNodeBase[] = []; - for (const [, node] of nodes) { + for (const node of nodes.values()) { const { measured, selectable = true, hidden = false } = node; - const width = measured.width ?? node.width ?? node.initialWidth ?? null; - const height = measured.height ?? node.height ?? node.initialHeight ?? null; if ((excludeNonSelectableNodes && !selectable) || hidden) { continue; } + const width = measured.width ?? node.width ?? node.initialWidth ?? null; + const height = measured.height ?? node.height ?? node.initialHeight ?? null; + const overlappingArea = getOverlappingArea(paneRect, nodeToRect(node)); - const notInitialized = width === null || height === null; + const area = (width ?? 0) * (height ?? 0); const partiallyVisible = partially && overlappingArea > 0; - const area = (width ?? 0) * (height ?? 0); - const isVisible = notInitialized || partiallyVisible || overlappingArea >= area; + const forceInitialRender = !node.internals.handleBounds; + const isVisible = forceInitialRender || partiallyVisible || overlappingArea >= area; if (isVisible || node.dragging) { visibleNodes.push(node);