aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2026-05-11 11:28:43 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2026-05-11 11:28:43 +0200
commitd4deaf0b8e88123b15ae7358c7bc049c143084fa (patch)
tree3a3c1440b652086a1e104cae83578395f3d9aed2 /templates
parent2ea8e9a472e4d726481a3ca99dbc988fb476e79e (diff)
feat: afficher la miniature en placeholder dans le lightbox pendant le chargement
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'templates')
-rw-r--r--templates/gallery.html24
1 files changed, 20 insertions, 4 deletions
diff --git a/templates/gallery.html b/templates/gallery.html
index 14e43c9..d21b518 100644
--- a/templates/gallery.html
+++ b/templates/gallery.html
@@ -84,18 +84,34 @@ function uploadFiles(files) {
}
const photos = [{{range .Photos}}'/g/{{$.Name}}/photo/{{.}}',{{end}}];
+const thumbs = [{{range .Photos}}'/g/{{$.Name}}/{{$.ThumbPrefix}}/{{.}}',{{end}}];
let currentIndex = -1;
function openLightbox(index) {
currentIndex = index;
- const src = photos[index];
- document.getElementById('lightbox-img').src = src;
- document.getElementById('lightbox-download').href = src;
+ const fullSrc = photos[index];
+ const img = document.getElementById('lightbox-img');
+
+ img.src = thumbs[index];
+ img.classList.add('loading');
+
+ const full = new Image();
+ full.onload = () => {
+ if (currentIndex === index) {
+ img.src = fullSrc;
+ img.classList.remove('loading');
+ }
+ };
+ full.src = fullSrc;
+
+ document.getElementById('lightbox-download').href = fullSrc;
document.getElementById('lightbox').classList.add('active');
}
function closeLightbox() {
document.getElementById('lightbox').classList.remove('active');
- document.getElementById('lightbox-img').src = '';
+ const img = document.getElementById('lightbox-img');
+ img.src = '';
+ img.classList.remove('loading');
currentIndex = -1;
}
document.addEventListener('keydown', e => {