fix: smooth NP swipe-open animation; live playing highlight in song lists

Swipe animation:
- _resetDrag(true) now reads the overlay's current drag position and starts
  the CSS transition from there instead of resetting to translateY(100%) first.
  That reset was causing the visible stutter (overlay jumped off-screen then
  slid back up). Now the overlay continues seamlessly from wherever the finger
  released to translateY(0).

Playing highlight:
- makeSongItem: adds data-song-id attribute to every .song-item element.
- updatePlayerUI: calls _updatePlayingHighlights() after every track change.
  This toggles .playing on all visible song items in any open list/playlist/
  favorites view so the highlighted row always matches what's actually playing,
  without requiring the user to navigate away and back.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
HoneyandClaude Sonnet 4.6 committed 2026-05-18 23:10:03 +02:00
1 parent 0fbb1385f1
commit b0fb1b200d
3 files changed
+32 -2

No files matched your search

+8
View File
@@ -356,6 +356,13 @@ export function playCurrent() {
});
}
function _updatePlayingHighlights() {
const id = String(S.queue[S.qIdx]?.id ?? '');
document.querySelectorAll('.song-item[data-song-id]').forEach(el => {
el.classList.toggle('playing', el.dataset.songId === id);
});
}
export function updatePlayerUI(s, _skipMediaSession = false) {
document.getElementById('player-title').textContent = s.title;
const artistParts = (s.artist || '').split(/\s*(?:\/|•|,)\s*/).filter(Boolean);
@@ -387,6 +394,7 @@ export function updatePlayerUI(s, _skipMediaSession = false) {
}));
} catch {}
_syncNpDirect(s);
_updatePlayingHighlights();
// Preload the hi-res NP cover now so opening the overlay is instant
const _npCv = coverUrl(s.coverArt, 1024);
if (_npCv && _npCv !== _npBgLastUrl) { const _pre = new Image(); _pre.src = _npCv; }