From bd8919fb392fd07a97436162ac51d89724f42eed Mon Sep 17 00:00:00 2001 From: Honey Date: Sun, 17 May 2026 21:05:55 +0200 Subject: [PATCH] fix: prevent accidental seek on tap in mobile progress bar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Touch scrubbing now requires ≥8px horizontal drag before committing. A plain tap on the progress bar is ignored — no unintentional position jump. Also removed redundant onclick="seekTo()" since _initBarScrub already handles mouse seeking via mousedown/mousemove/mouseup. Co-Authored-By: Claude Sonnet 4.6 --- index.html | 2 +- src/player.js | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index d81c043..6031061 100644 --- a/index.html +++ b/index.html @@ -436,7 +436,7 @@
0:00 -
+
0:00
diff --git a/src/player.js b/src/player.js index 0ecd8ca..535ba0f 100644 --- a/src/player.js +++ b/src/player.js @@ -670,9 +670,24 @@ function _initBarScrub(bar, fill, onMove) { fill.style.transition = ''; } } - bar.addEventListener('touchstart', e => { startScrub(getPos(e.touches[0].clientX)); e.stopPropagation(); }, {passive:true}); - bar.addEventListener('touchmove', e => { if(S._scrubbing) moveScrub(getPos(e.touches[0].clientX)); }, {passive:true}); - bar.addEventListener('touchend', e => { if(S._scrubbing) endScrub(getPos(e.changedTouches[0].clientX)); }, {passive:true}); + // Touch: require ≥8px horizontal drag before committing to scrub. + // A plain tap cancels cleanly without seeking. + let _touchStartX = 0, _touchMoved = false; + bar.addEventListener('touchstart', e => { + _touchStartX = e.touches[0].clientX; + _touchMoved = false; + e.stopPropagation(); + }, {passive:true}); + bar.addEventListener('touchmove', e => { + const dx = Math.abs(e.touches[0].clientX - _touchStartX); + if (!_touchMoved && dx >= 8) { _touchMoved = true; startScrub(getPos(e.touches[0].clientX)); } + if (_touchMoved && S._scrubbing) moveScrub(getPos(e.touches[0].clientX)); + }, {passive:true}); + bar.addEventListener('touchend', e => { + if (_touchMoved && S._scrubbing) endScrub(getPos(e.changedTouches[0].clientX)); + else S._scrubbing = false; + _touchMoved = false; + }, {passive:true}); bar.addEventListener('mousedown', e => { startScrub(getPos(e.clientX)); e.preventDefault(); const mm = e2 => { if(S._scrubbing) moveScrub(getPos(e2.clientX)); };