This is an automated email from the ASF dual-hosted git repository. wangzx pushed a commit to branch fix/tooltip/cleanup-styleCoord-markers in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 78727051d9d8d16829fec1830df56a0b98453d07 Author: plainheart <[email protected]> AuthorDate: Thu May 22 01:28:45 2025 +0800 fix(tooltip): fix style coord transform markers are not removed after the tooltip is disposed --- src/component/tooltip/TooltipHTMLContent.ts | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/component/tooltip/TooltipHTMLContent.ts b/src/component/tooltip/TooltipHTMLContent.ts index f03bcd8f1..6bc72919c 100644 --- a/src/component/tooltip/TooltipHTMLContent.ts +++ b/src/component/tooltip/TooltipHTMLContent.ts @@ -227,7 +227,7 @@ function makeStyleCoord( const zrViewportRoot = zrPainter && zrPainter.getViewportRoot(); if (zrViewportRoot) { // Some APPs might use scale on body, so we support CSS transform here. - transformLocalCoord(out, zrViewportRoot, container, zrX, zrY); + return transformLocalCoord(out, zrViewportRoot, container, zrX, zrY); } } else { @@ -265,6 +265,7 @@ class TooltipHTMLContent { private _show: boolean = false; private _styleCoord: [number, number, number, number] = [0, 0, 0, 0]; + private _styleCoordCleanups: ReturnType<typeof makeStyleCoord>; private _enterable = true; private _zr: ZRenderType; @@ -307,7 +308,9 @@ class TooltipHTMLContent { : isFunction(appendTo) && appendTo(api.getDom()) ); - makeStyleCoord(this._styleCoord, zr, container, api.getWidth() / 2, api.getHeight() / 2); + this._styleCoordCleanups = makeStyleCoord( + this._styleCoord, zr, container, api.getWidth() / 2, api.getHeight() / 2 + ); (container || api.getDom()).appendChild(el); @@ -471,7 +474,7 @@ class TooltipHTMLContent { return; } const styleCoord = this._styleCoord; - makeStyleCoord(styleCoord, this._zr, this._container, zrX, zrY); + this._styleCoordCleanups = makeStyleCoord(styleCoord, this._zr, this._container, zrX, zrY); if (styleCoord[0] != null && styleCoord[1] != null) { const style = this.el.style; @@ -528,9 +531,16 @@ class TooltipHTMLContent { clearTimeout(this._hideTimeout); clearTimeout(this._longHideTimeout); - const parentNode = this.el.parentNode; - parentNode && parentNode.removeChild(this.el); - this.el = this._container = null; + each(this._styleCoordCleanups, function (cleanup) { + cleanup(); + }); + + if (this.el) { + const parentNode = this.el.parentNode; + parentNode && parentNode.removeChild(this.el); + } + + this._styleCoordCleanups = this.el = this._container = null; } } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
