Changeset a64d705 in Klonkt for src/views/shell.ejs


Ignore:
Timestamp:
06/28/2026 05:25:46 PM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
600fbf3
Parents:
201ec06
Message:

feat(images): accent-gradient placeholder while covers load + fade-in

Cover tiles/cards now show an accent-coloured gradient placeholder while the image loads
(instead of a white flash), and the cover fades in once loaded. Cached images stay instant.
Makes image-heavy pages feel responsive even before thumbnails finish.

  • assets/css/style.css — grid-tile gradient placeholder; grid-tile-img white moved to img + fade
  • views/partials/post-card.ejs — post-list-cover gradient placeholder + img fade
  • views/shell.ejs — cover fade-in script (hide-while-loading, instant for cached); buster v=61
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/views/shell.ejs

    r201ec06 ra64d705  
    200200
    201201<!-- v9 stylesheet (full palette system) -->
    202 <link rel="stylesheet" href="/assets/css/style.css?v=60">
     202<link rel="stylesheet" href="/assets/css/style.css?v=61">
    203203<script>
    204204/* iOS safe-area, built by hand. env(safe-area-inset-top) resolves to 0 on this iOS in
     
    737737     click reveals instead of following the card link or firing htmx navigation. -->
    738738<script>
     739// Cover fade-in: a cover image that's still loading is hidden so the accent-gradient
     740// placeholder behind it shows; it fades in once loaded. Cached/complete images stay
     741// visible (no flash). Runs on load + htmx swaps.
     742(function () {
     743  if (window.__coverFadeWired) return; window.__coverFadeWired = true;
     744  function scan(root) {
     745    (root || document).querySelectorAll('.grid-tile-img, .post-list-cover img').forEach(function (img) {
     746      if (img.dataset.fade) return; img.dataset.fade = '1';
     747      if (img.complete && img.naturalWidth > 0) return;   // already loaded → leave visible
     748      img.classList.add('is-loading');
     749      var done = function () { img.classList.remove('is-loading'); };
     750      img.addEventListener('load', done, { once: true });
     751      img.addEventListener('error', done, { once: true });
     752    });
     753  }
     754  scan(document);
     755  document.body.addEventListener('htmx:afterSettle', function (e) { scan(e.target); });
     756})();
     757</script>
     758
     759<script>
    739760(function () {
    740761  if (window.__nsfwWired) return; window.__nsfwWired = true;
Note: See TracChangeset for help on using the changeset viewer.