diff --git a/config.php b/config.php index 77c3626..d26cc3a 100644 --- a/config.php +++ b/config.php @@ -1,7 +1,7 @@ { clearTimeout(showTimer); hide(); }, true); document.addEventListener('keydown', () => { clearTimeout(showTimer); hide(); }, true); document.addEventListener('scroll', () => { clearTimeout(showTimer); hide(); }, true); + +// Belt-and-suspenders sanity check on every move: if the pointer is +// no longer over the tip-owning target (or the target has been +// detached from the DOM since show time), hide. Catches fast flicks +// that skip the expected pointerleave and DOM churn that yanks the +// element out from under us. +document.addEventListener('pointermove', (e) => { + if (!currentTarget) return; + if (!currentTarget.isConnected) { hide(); return; } + const el = document.elementFromPoint(e.clientX, e.clientY); + if (!el || !currentTarget.contains(el)) hide(); +}, true); + +// Window losing focus / tab hidden — nothing to hover over while +// we're not there, kill any lingering tip. +window.addEventListener('blur', () => { clearTimeout(showTimer); hide(); }); +document.addEventListener('visibilitychange', () => { if (document.hidden) { clearTimeout(showTimer); hide(); } });