diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-04-03 09:09:39 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-04-03 09:09:39 -0300 |
commit | 28c2b923775d440eb8606a824651236bfae0b0cf (patch) | |
tree | d909c3ff6c9fce880f9dd6d8c815f0ce62406b2c | |
parent | 857858ca9c5ce220242676561190dfc2c9713fbc (diff) |
client: smarter tooltip touchend -> click banishing
-rw-r--r-- | src/static/client3.js | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/static/client3.js b/src/static/client3.js index f86fd840..7d6544a0 100644 --- a/src/static/client3.js +++ b/src/static/client3.js @@ -1337,7 +1337,25 @@ function handleTooltipHoverableTouchEnded(hoverable, domEvent) { // Don't proceed if this hoverable's tooltip is already visible - in that // case touching the hoverable again should behave just like a normal click. - if (state.currentlyShownTooltip === tooltip) return; + if (state.currentlyShownTooltip === tooltip) { + // If the hoverable was *recently* touched - meaning that this is a second + // touchend in short succession - then just letting the click come through + // naturally would (depending on timing) not actually navigate anywhere, + // because we've deliberately banished the *first* touch from navigation. + // We do want the second touch to navigate, so clear that recently-touched + // state, allowing this touch's click to behave as normal. + if (state.hoverableWasRecentlyTouched) { + clearTimeout(state.touchTimeout); + state.touchTimeout = null; + state.hoverableWasRecentlyTouched = false; + } + + // Otherwise, this is just a second touch after enough time has passed + // that the one which showed the tooltip is no longer "recent", and we're + // not in any special state. The link will navigate to its page just like + // normal. + return; + } const touches = Array.from(domEvent.changedTouches); const identifiers = touches.map(touch => touch.identifier); @@ -1379,8 +1397,9 @@ function handleTooltipHoverableTouchEnded(hoverable, domEvent) { state.hoverableWasRecentlyTouched = true; state.touchTimeout = setTimeout(() => { + state.touchTimeout = null; state.hoverableWasRecentlyTouched = false; - }, 250); + }, 1200); } function handleTooltipHoverableClicked(hoverable) { |