Skip to content

Commit 67a6761

Browse files
Copilotbrunoborges
andcommitted
Improve tap detection with distance threshold
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
1 parent 0c4762d commit 67a6761

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

app.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@
191191
let touchStartY = 0;
192192
let touchEndX = 0;
193193
let touchEndY = 0;
194-
let isSwiping = false;
195194

196195
// Track touch start
197196
card.addEventListener('touchstart', (e) => {
@@ -200,13 +199,6 @@
200199

201200
touchStartX = e.changedTouches[0].clientX;
202201
touchStartY = e.changedTouches[0].clientY;
203-
isSwiping = false;
204-
}, { passive: true });
205-
206-
// Track touch move to detect swipe
207-
card.addEventListener('touchmove', (e) => {
208-
if (!e.target.closest('.card-code')) return;
209-
isSwiping = true;
210202
}, { passive: true });
211203

212204
// Handle touch end for swipe or tap
@@ -234,8 +226,8 @@
234226
// Swipe right - show old
235227
card.classList.remove('toggled');
236228
}
237-
} else if (!isSwiping) {
238-
// It's a tap (no significant movement)
229+
} else if (absDeltaX < 10 && absDeltaY < 10) {
230+
// It's a tap (movement under 10px threshold)
239231
card.classList.toggle('toggled');
240232
}
241233
}, { passive: true });

0 commit comments

Comments
 (0)