Skip to content

Commit c06ede0

Browse files
Copilotbrunoborges
andcommitted
Add clarifying comments for event handling
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
1 parent 34d4cee commit c06ede0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

app.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
}, { passive: true });
203203

204204
// Handle touch end for swipe or tap
205+
// Note: passive:false allows us to preventDefault on tap/swipe while still allowing vertical scrolling
205206
card.addEventListener('touchend', (e) => {
206207
// Only handle touches on the card-code area
207208
if (!e.target.closest('.card-code')) return;
@@ -218,7 +219,7 @@
218219
const isHorizontalSwipe = absDeltaX > 50 && absDeltaX > absDeltaY;
219220

220221
if (isHorizontalSwipe) {
221-
// Prevent default navigation
222+
// Prevent default navigation for horizontal swipes
222223
e.preventDefault();
223224
// Swipe left = show modern, swipe right = show old
224225
if (deltaX < 0) {
@@ -233,10 +234,11 @@
233234
e.preventDefault();
234235
card.classList.toggle('toggled');
235236
}
237+
// Note: Vertical scrolling (large deltaY, small deltaX) doesn't call preventDefault
236238
}, { passive: false });
237239

238-
// Prevent click events on card-code from navigating
239-
// (the touch handlers above already handle the interaction)
240+
// Prevent click events on card-code from navigating (touch devices only)
241+
// This is a safety net in case touch events trigger click as fallback
240242
card.addEventListener('click', (e) => {
241243
if (e.target.closest('.card-code')) {
242244
e.preventDefault();

0 commit comments

Comments
 (0)