From fbf37ffdc981839a54cc2dcd41513e54eb0c9bad Mon Sep 17 00:00:00 2001 From: Aaron Date: Tue, 5 Nov 2024 20:02:52 +0800 Subject: [PATCH] fix: destroy substitute shape after measure bounds (#6478) Co-authored-by: antv --- packages/g6/src/elements/nodes/base-node.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/g6/src/elements/nodes/base-node.ts b/packages/g6/src/elements/nodes/base-node.ts index 76340222ad1..1c4de197ac3 100644 --- a/packages/g6/src/elements/nodes/base-node.ts +++ b/packages/g6/src/elements/nodes/base-node.ts @@ -460,7 +460,7 @@ function getBoundsInOffscreen(context: RuntimeContext, shape: DisplayObject) { if (!context) return shape.getLocalBounds(); // 将主图形靠背至全局空间,避免受到父级 transform 的影响 - // 合理的操作应该是靠背至离屏画布,但目前 G 有点问题 + // 合理的操作应该是拷贝至离屏画布,但目前 G 有点问题 // Move the main graphic to the global space to avoid being affected by the parent transform // The reasonable operation should be moved to the off-screen canvas, but there is a problem with G at present const canvas = context.canvas.getLayer(); @@ -468,7 +468,7 @@ function getBoundsInOffscreen(context: RuntimeContext, shape: DisplayObject) { setVisibility(substitute, 'hidden'); canvas.appendChild(substitute); const bounds = substitute.getLocalBounds(); - canvas.removeChild(substitute); + substitute.destroy(); return bounds; }