Changeset 5258945 in Klonkt for src/assets/js


Ignore:
Timestamp:
06/20/2026 02:17:12 AM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
795c925
Parents:
ddf549f
Message:

feat(player): persistent highlight on the active track

The currently playing track gets a persistent highlight (.pat-playing, accent
border + tint) for as long as it is the current one; markPlaying() runs on
every loadTrack and is re-applied after htmx navigation. The short spring
pulse (pat-flash) remains. busters: audio-player.js?v=19, style.css?v=18.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/assets/js/audio-player.js

    rddf549f r5258945  
    276276  // Used by the site pre-seed so opening a page doesn't auto-download audio;
    277277  // the blob is fetched lazily on the first play().
     278  // Markeer de huidige track persistent (blijvende highlight zolang 'ie actief is).
     279  function markPlaying(trackId) {
     280    document.querySelectorAll('.pat-playing').forEach((e) => e.classList.remove('pat-playing'));
     281    if (!trackId) return;
     282    const el = document.getElementById('track-' + trackId);
     283    if (el) el.classList.add('pat-playing');
     284  }
     285  // Na een htmx-navigatie is de post-DOM vervangen → highlight opnieuw zetten.
     286  document.body.addEventListener('htmx:afterSettle', () => {
     287    const t = queue[currentIndex];
     288    if (t) markPlaying(t.id);
     289  });
     290
    278291  function loadTrack(index, autoplay, metaOnly) {
    279292    if (!queue[index]) {
     
    300313    document.body.classList.add('has-audio-player');
    301314    renderQueue();
     315    markPlaying(t.id);
    302316
    303317    if (metaOnly) return;
Note: See TracChangeset for help on using the changeset viewer.