« get me outta code hell

client: whenTooltipShows, whenTooltipHides - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-03-29 14:23:59 -0300
committer(quasar) nebula <qznebula@protonmail.com>2024-03-29 20:01:45 -0300
commit6817e9d085345ac6b26a5c7b90d963c3d4bf630d (patch)
tree053f4c9a403086b267c340341af3b707dc60a4a5 /src
parent281e5fa90615bde3a3cc5b84ab38521a69dd6ba3 (diff)
client: whenTooltipShows, whenTooltipHides
Diffstat (limited to 'src')
-rw-r--r--src/static/client3.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/static/client3.js b/src/static/client3.js
index 1554e321..5738b46f 100644
--- a/src/static/client3.js
+++ b/src/static/client3.js
@@ -1075,6 +1075,11 @@ const hoverableTooltipInfo = initInfo('hoverableTooltipInfo', {
     currentTouchIdentifiers: new Set(),
     touchIdentifiersBanishedByScrolling: new Set(),
   },
+
+  event: {
+    whenTooltipShows: [],
+    whenTooltipHides: [],
+  },
 });
 
 // Adds DOM event listeners, so must be called during addPageListeners step.
@@ -1476,7 +1481,7 @@ function endTransitioningTooltipHidden() {
 }
 
 function hideCurrentlyShownTooltip(intendingToReplace = false) {
-  const {settings, state} = hoverableTooltipInfo;
+  const {settings, state, event} = hoverableTooltipInfo;
   const {currentlyShownTooltip: tooltip} = state;
 
   // If there was no tooltip to begin with, we're functionally in the desired
@@ -1516,11 +1521,15 @@ function hideCurrentlyShownTooltip(intendingToReplace = false) {
     state.tooltipWasJustHidden = false;
   });
 
+  dispatchInternalEvent(event, 'whenTooltipHides', {
+    tooltip,
+  });
+
   return true;
 }
 
 function showTooltipFromHoverable(hoverable) {
-  const {state} = hoverableTooltipInfo;
+  const {state, event} = hoverableTooltipInfo;
   const {tooltip} = state.registeredHoverables.get(hoverable);
 
   if (!hideCurrentlyShownTooltip(true)) return false;
@@ -1541,6 +1550,10 @@ function showTooltipFromHoverable(hoverable) {
 
   state.tooltipWasJustHidden = false;
 
+  dispatchInternalEvent(event, 'whenTooltipShows', {
+    tooltip,
+  });
+
   return true;
 }