From d545e13fbe044efe0a4c7fda68affb7cc3352696 Mon Sep 17 00:00:00 2001
From: Alan Grainger <16197738+alangrainger@users.noreply.github.com>
Date: Sat, 30 May 2026 11:46:52 +0800
Subject: [PATCH] Fade thumbnails in over thumbhash on load
---
app/public/style.css | 15 +++++++++------
app/public/web.js | 5 +++++
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/app/public/style.css b/app/public/style.css
index d563fed..d754b43 100644
--- a/app/public/style.css
+++ b/app/public/style.css
@@ -108,14 +108,17 @@ html, body {
width: 100%;
height: 100%;
object-fit: cover;
+ opacity: 0;
+ transition: opacity 0.25s ease-out;
}
-/* Hide the
until JS sets its src - otherwise Chrome renders its default
- broken-image glyph for img elements with explicit dimensions but no src
- (e.g. tiles awaiting load, or tiles whose in-flight fetch was cancelled
- when the user scrolled past). The 's gray background shows through. */
-#gallery img:not([src]) {
- visibility: hidden;
+/* Fade the thumbnail in once its bytes are decoded (web.js adds .loaded on
+ the img's load event). While opacity is 0 the 's thumbhash / gray
+ background shows through, so the blurred thumbhash appears to resolve into
+ the sharp image rather than snap. Also masks the brief white flash Chrome /
+ Edge paint between `img.src` being set and the bytes actually rendering. */
+#gallery img.loaded {
+ opacity: 1;
}
#gallery a.thumb-error img {
diff --git a/app/public/web.js b/app/public/web.js
index 6f85ad8..945b698 100644
--- a/app/public/web.js
+++ b/app/public/web.js
@@ -316,6 +316,11 @@ function createTile (index) {
img.alt = ''
img.dataset.src = item.thumbnailUrl
img.onerror = onThumbError
+ // Mark the image as drawable once its bytes are decoded; the CSS rule
+ // `#gallery img.loaded` fades opacity from 0 to 1 so the thumbhash blurs
+ // into the sharp image instead of snapping (and masks Chrome/Edge's brief
+ // white flash between `img.src` being set and the bytes actually painting).
+ img.onload = () => img.classList.add('loaded')
a.appendChild(img)
if (item.type === 'VIDEO') {