diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/Tooltip/tooltip.ts | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/lib/Tooltip/tooltip.ts b/src/lib/Tooltip/tooltip.ts index b1381b62..348689b1 100644 --- a/src/lib/Tooltip/tooltip.ts +++ b/src/lib/Tooltip/tooltip.ts @@ -89,14 +89,13 @@ const tooltip = (element: HTMLElement) => { }; const hideTooltip = () => { - hideTimeout = window.setTimeout(() => { + setTimeout(() => { if (tooltipDiv) { tooltipDiv.style.opacity = '0'; - setTimeout(() => { + hideTimeout = window.setTimeout(() => { if (tooltipDiv) { document.body.removeChild(tooltipDiv); - tooltipDiv = null; } }, tooltipTransitionTime); @@ -109,7 +108,15 @@ const tooltip = (element: HTMLElement) => { if (title) { element.removeAttribute('title'); - showTooltip(title, event.pageX, event.pageY); + + if (hideTimeout !== null) { + clearTimeout(hideTimeout); + hideTimeout = null; + } + + if (!tooltipDiv) { + showTooltip(title, event.pageX, event.pageY); + } } }; |