« get me outta code hell

only animate info card hiding if it's shown - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-04-06 14:33:57 -0300
committer(quasar) nebula <towerofnix@gmail.com>2021-04-06 14:33:57 -0300
commitdfd82901f2bc80494c984480ff875200230c0d55 (patch)
treebdbbba8978a8488193884b2050066b74be96a16f
parente11c6707e9279d20c1a6373672ba6b3cd684f829 (diff)
only animate info card hiding if it's shown
This fixes a glitch where it'd trigger the hide animation just by
passing the cursor over the link for even an instant. Not good!
-rw-r--r--static/client.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/static/client.js b/static/client.js
index fe4f5c4..d2ca95c 100644
--- a/static/client.js
+++ b/static/client.js
@@ -239,6 +239,7 @@ const infoCard = (() => {
 
     let cancelShow = false;
     let hideTimeout = null;
+    let showing = false;
 
     container.addEventListener('mouseenter', cancelHide);
     container.addEventListener('mouseleave', readyHide);
@@ -253,6 +254,8 @@ const infoCard = (() => {
                 return;
             }
 
+            showing = true;
+
             const rect = target.getBoundingClientRect();
 
             container.style.setProperty('--primary-color', data.color);
@@ -333,10 +336,11 @@ const infoCard = (() => {
         container.classList.remove('show');
         container.classList.add('hide');
         cancelShow = true;
+        showing = false;
     }
 
     function readyHide() {
-        if (!hideTimeout) {
+        if (!hideTimeout && showing) {
             hideTimeout = setTimeout(hide, HIDE_HOVER_DELAY);
         }
     }