Skip to content

Commit

Permalink
fix: destroy substitute shape after measure bounds (#6478)
Browse files Browse the repository at this point in the history
Co-authored-by: antv <[email protected]>
  • Loading branch information
Aarebecca and antv authored Nov 5, 2024
1 parent 49ba7ff commit fbf37ff
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/g6/src/elements/nodes/base-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,15 +460,15 @@ 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();
const substitute = shape.cloneNode();
setVisibility(substitute, 'hidden');
canvas.appendChild(substitute);
const bounds = substitute.getLocalBounds();
canvas.removeChild(substitute);
substitute.destroy();

return bounds;
}

0 comments on commit fbf37ff

Please sign in to comment.