Browse Source

Fix double-tap proximity detection

- 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 <noreply@anthropic.com>
master
HikeMap User 1 month ago
parent
commit
b9ab9093f2
  1. 28
      index.html

28
index.html

@ -4247,9 +4247,23 @@
const now = Date.now();
const timeSinceLastTap = now - lastTapTime;
// 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 };
}
// Check for double-tap (two taps within 300ms at roughly same location)
if (timeSinceLastTap < 300 && lastTapLocation && pendingDestination) {
// Double-tap detected - show navigation dialog
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();
@ -4261,12 +4275,14 @@
lastTapTime = 0; // Reset to prevent triple tap
lastTapLocation = null;
} else {
// Store this tap for double-tap detection
// Taps too far apart - treat as new first tap
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;
}
} else {
// Store this tap for double-tap detection
lastTapTime = now;
lastTapLocation = currentTapLocation;
}
if (isPressing) {

Loading…
Cancel
Save