Skip to content

Commit faa83d6

Browse files
committed
feat: enhance touch navigation by ignoring swipes on interactive elements
1 parent 112e7e6 commit faa83d6

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

static/js/v2-announcement.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,20 @@ class V2Announcement {
156156
let startX = 0;
157157
let startY = 0;
158158

159+
const interactiveTags = new Set(['BUTTON', 'A', 'INPUT', 'TEXTAREA', 'SELECT']);
160+
159161
wrapper.addEventListener('touchstart', (e) => {
162+
// Ignore swipes starting on interactive elements
163+
if (interactiveTags.has(e.target.tagName) || e.target.closest('button, a, input')) {
164+
startX = null;
165+
return;
166+
}
160167
startX = e.touches[0].clientX;
161168
startY = e.touches[0].clientY;
162169
}, { passive: true });
163170

164171
wrapper.addEventListener('touchend', (e) => {
165-
if (!this.modalShown) return;
172+
if (!this.modalShown || startX === null) return;
166173
const dx = e.changedTouches[0].clientX - startX;
167174
const dy = e.changedTouches[0].clientY - startY;
168175
// only count horizontal swipes (ignore vertical scrolls)

0 commit comments

Comments
 (0)