From 4c03bc00eb8751c5d81f114d811d46eaff35883e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Wed, 18 May 2022 15:09:46 +0200 Subject: [PATCH] Refactor tooltip management a little --- src/ts/RemoteCursorWidget.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/ts/RemoteCursorWidget.ts b/src/ts/RemoteCursorWidget.ts index 12eb600..d5a2897 100644 --- a/src/ts/RemoteCursorWidget.ts +++ b/src/ts/RemoteCursorWidget.ts @@ -171,17 +171,10 @@ export class RemoteCursorWidget implements editor.IContentWidget, IDisposable { } private _showTooltip(): void { - this._updateTooltipPosition(); - - if (this._hideTimer !== null) { - clearTimeout(this._hideTimer); - } else { - this._setTooltipVisible(true); - } + this._setTooltipVisible(true); this._hideTimer = setTimeout(() => { this._setTooltipVisible(false); - this._hideTimer = null; }, this._tooltipDuration); } @@ -197,7 +190,12 @@ export class RemoteCursorWidget implements editor.IContentWidget, IDisposable { } private _setTooltipVisible(visible: boolean): void { + if (this._hideTimer !== null) { + clearTimeout(this._hideTimer); + this._hideTimer = null; + } if (visible) { + this._updateTooltipPosition(); this._tooltipNode.style.opacity = "1.0"; } else { this._tooltipNode.style.opacity = "0";