From ea4bae05113b2f70298c35535187dcb4fb557db0 Mon Sep 17 00:00:00 2001 From: Aaron Date: Fri, 3 Jan 2025 19:43:47 +0800 Subject: [PATCH] refactor: minimap wont override specified container style (#6693) --- packages/g6/src/plugins/utils/canvas.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/g6/src/plugins/utils/canvas.ts b/packages/g6/src/plugins/utils/canvas.ts index e173b0ce361..e4e1a567406 100644 --- a/packages/g6/src/plugins/utils/canvas.ts +++ b/packages/g6/src/plugins/utils/canvas.ts @@ -33,18 +33,8 @@ interface Options { * @returns [容器, 画布] | [container, canvas] */ export function createPluginCanvas(options: Options): [HTMLElement, GCanvas] { - const { width, height, renderer, containerStyle } = options; + const { width, height, renderer } = options; const $container = getContainer(options); - const [x, y] = computePosition(options); - - Object.assign($container.style, { - position: 'absolute', - left: x + 'px', - top: y + 'px', - width: width + 'px', - height: height + 'px', - ...containerStyle, - }); const canvas = new GCanvas({ width, @@ -70,6 +60,19 @@ function getContainer(options: Options) { } const $container = createPluginContainer(className, false); + + const { width, height, containerStyle } = options; + const [x, y] = computePosition(options); + + Object.assign($container.style, { + position: 'absolute', + left: x + 'px', + top: y + 'px', + width: width + 'px', + height: height + 'px', + ...containerStyle, + }); + graphCanvas.getContainer()?.appendChild($container); return $container; }