diff --git a/src/lib/swipe.js b/src/lib/swipe.js index dd5fa86..3037c5f 100644 --- a/src/lib/swipe.js +++ b/src/lib/swipe.js @@ -32,11 +32,19 @@ export function onSwipe(target, { onLeft, onRight, threshold = 60 } = {}) { const dx = e.touches[0].clientX - x0; const dy = e.touches[0].clientY - y0; if (!claimed) { - if (Math.abs(dy) > 12 && Math.abs(dy) > Math.abs(dx)) { - active = false; // it's a vertical scroll — let it be + const adx = Math.abs(dx); + const ady = Math.abs(dy); + // Scroll is the default: bail out — permanently — at the first sign of + // vertical intent, even a mildly diagonal one. A page full of scrolling + // content (tab panels, lists) means a fast flick's first sample is + // often diagonal; without this bias it gets misread as a page-swipe + // and the rest of the scroll gets eaten by preventDefault(). + if (ady > 10 && ady > adx * 0.7) { + active = false; return; } - if (Math.abs(dx) > 10 && Math.abs(dx) > Math.abs(dy)) claimed = true; + // Only claim a horizontal page-swipe once the drag is unambiguous. + if (adx > 20 && adx > ady * 2) claimed = true; } if (claimed) e.preventDefault(); };