aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-04-16 01:10:53 -0700
committerFuwn <[email protected]>2024-04-16 01:27:26 -0700
commit1d52862ab11f979c792239b63423e8d65c31b37b (patch)
tree9e39a855a233afa2732d188ae0198e79aace7dfc /src
parentfix(badges): empty fields (diff)
downloaddue.moe-1d52862ab11f979c792239b63423e8d65c31b37b.tar.xz
due.moe-1d52862ab11f979c792239b63423e8d65c31b37b.zip
fix(tooltip): fix despawn on quick hover
Diffstat (limited to 'src')
-rw-r--r--src/lib/Tooltip/tooltip.ts15
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);
+ }
}
};