From b9ab9093f2a25bbd4fa923a0c1b91e1b2e933cec Mon Sep 17 00:00:00 2001 From: HikeMap User Date: Wed, 31 Dec 2025 09:41:06 -0600 Subject: [PATCH] Fix double-tap proximity detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Double-tap now requires both taps to be within 30 pixels of each other - Prevents accidental navigation from taps with different fingers - If second tap is too far away, it starts a new double-tap sequence This ensures double-tap only works when intentionally tapping the same spot twice. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- index.html | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index 30b4773..3df51d7 100644 --- a/index.html +++ b/index.html @@ -4247,26 +4247,42 @@ const now = Date.now(); const timeSinceLastTap = now - lastTapTime; - // Check for double-tap (two taps within 300ms at roughly same location) - if (timeSinceLastTap < 300 && lastTapLocation && pendingDestination) { - // Double-tap detected - show navigation dialog - e.preventDefault(); - e.stopPropagation(); - - document.getElementById('pressHoldIndicator').style.display = 'none'; - const message = `Navigate to ${pendingDestination.track.name}?`; - document.getElementById('navConfirmMessage').textContent = message; - document.getElementById('navConfirmDialog').style.display = 'flex'; + // Get current tap location + let currentTapLocation = null; + if (e.changedTouches && e.changedTouches.length > 0) { + const touch = e.changedTouches[0]; + currentTapLocation = { x: touch.clientX, y: touch.clientY }; + } - lastTapTime = 0; // Reset to prevent triple tap - lastTapLocation = null; + // Check for double-tap (two taps within 300ms at roughly same location) + if (timeSinceLastTap < 300 && lastTapLocation && currentTapLocation && pendingDestination) { + // Calculate distance between taps + const dx = currentTapLocation.x - lastTapLocation.x; + const dy = currentTapLocation.y - lastTapLocation.y; + const distance = Math.sqrt(dx * dx + dy * dy); + + // Only trigger if taps are within 30 pixels of each other + if (distance < 30) { + // Double-tap detected at same location - show navigation dialog + e.preventDefault(); + e.stopPropagation(); + + document.getElementById('pressHoldIndicator').style.display = 'none'; + const message = `Navigate to ${pendingDestination.track.name}?`; + document.getElementById('navConfirmMessage').textContent = message; + document.getElementById('navConfirmDialog').style.display = 'flex'; + + lastTapTime = 0; // Reset to prevent triple tap + lastTapLocation = null; + } else { + // Taps too far apart - treat as new first tap + lastTapTime = now; + lastTapLocation = currentTapLocation; + } } else { // Store this tap for double-tap detection lastTapTime = now; - if (e.touches.length === 0 && e.changedTouches.length > 0) { - const touch = e.changedTouches[0]; - lastTapLocation = { x: touch.clientX, y: touch.clientY }; - } + lastTapLocation = currentTapLocation; } if (isPressing) {