fix: Bug fixes Scrub lag Chapter track last chapter Mini bar stays over music Resume ABS doesn't stop music

This commit is contained in:
Honey committed 2026-05-03 16:47:17 +02:00
1 parent eb4d6fcbf9
commit 0d8b8b6f5d
3 files changed
+31 -6

No files matched your search

+11 -1
View File
@@ -235,7 +235,17 @@ function _initBarScrub(bar, fill, onMove) {
function getPos(clientX) { const r = bar.getBoundingClientRect(); return Math.max(0, Math.min(1, (clientX-r.left)/r.width)); }
function startScrub(pos) { S._scrubbing=true; fill.style.transition='none'; fill.style.width=(pos*100)+'%'; onMove(pos); }
function moveScrub(pos) { fill.style.width=(pos*100)+'%'; onMove(pos); }
function endScrub(pos) { S._scrubbing=false; fill.style.transition=''; if(S.audio.duration) S.audio.currentTime=pos*S.audio.duration; }
function endScrub(pos) {
fill.style.transition='';
if(S.audio.duration) {
S.audio.currentTime = pos * S.audio.duration;
// Keep _scrubbing=true until seek completes so timeupdate can't snap bar back
S.audio.addEventListener('seeked', () => { S._scrubbing = false; }, { once: true });
setTimeout(() => { S._scrubbing = false; }, 1500); // fallback if seeked never fires
} else {
S._scrubbing = false;
}
}
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});