Skip to content

Commit 7872705

Browse files
committed
fix(tooltip): fix style coord transform markers are not removed after the tooltip is disposed
1 parent fc6656f commit 7872705

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/component/tooltip/TooltipHTMLContent.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ function makeStyleCoord(
227227
const zrViewportRoot = zrPainter && zrPainter.getViewportRoot();
228228
if (zrViewportRoot) {
229229
// Some APPs might use scale on body, so we support CSS transform here.
230-
transformLocalCoord(out, zrViewportRoot, container, zrX, zrY);
230+
return transformLocalCoord(out, zrViewportRoot, container, zrX, zrY);
231231
}
232232
}
233233
else {
@@ -265,6 +265,7 @@ class TooltipHTMLContent {
265265
private _show: boolean = false;
266266

267267
private _styleCoord: [number, number, number, number] = [0, 0, 0, 0];
268+
private _styleCoordCleanups: ReturnType<typeof makeStyleCoord>;
268269

269270
private _enterable = true;
270271
private _zr: ZRenderType;
@@ -307,7 +308,9 @@ class TooltipHTMLContent {
307308
: isFunction(appendTo) && appendTo(api.getDom())
308309
);
309310

310-
makeStyleCoord(this._styleCoord, zr, container, api.getWidth() / 2, api.getHeight() / 2);
311+
this._styleCoordCleanups = makeStyleCoord(
312+
this._styleCoord, zr, container, api.getWidth() / 2, api.getHeight() / 2
313+
);
311314

312315
(container || api.getDom()).appendChild(el);
313316

@@ -471,7 +474,7 @@ class TooltipHTMLContent {
471474
return;
472475
}
473476
const styleCoord = this._styleCoord;
474-
makeStyleCoord(styleCoord, this._zr, this._container, zrX, zrY);
477+
this._styleCoordCleanups = makeStyleCoord(styleCoord, this._zr, this._container, zrX, zrY);
475478

476479
if (styleCoord[0] != null && styleCoord[1] != null) {
477480
const style = this.el.style;
@@ -528,9 +531,16 @@ class TooltipHTMLContent {
528531
clearTimeout(this._hideTimeout);
529532
clearTimeout(this._longHideTimeout);
530533

531-
const parentNode = this.el.parentNode;
532-
parentNode && parentNode.removeChild(this.el);
533-
this.el = this._container = null;
534+
each(this._styleCoordCleanups, function (cleanup) {
535+
cleanup();
536+
});
537+
538+
if (this.el) {
539+
const parentNode = this.el.parentNode;
540+
parentNode && parentNode.removeChild(this.el);
541+
}
542+
543+
this._styleCoordCleanups = this.el = this._container = null;
534544
}
535545

536546
}

0 commit comments

Comments
 (0)