From e48a1415a6a0ce04632d3e80b90a8c6ce4e42797 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 27 Apr 2025 11:46:42 +0100 Subject: [PATCH] don't set hash onload --- camp/static/js/gallery.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/camp/static/js/gallery.js b/camp/static/js/gallery.js index 410f55b..5fa58ef 100644 --- a/camp/static/js/gallery.js +++ b/camp/static/js/gallery.js @@ -217,7 +217,7 @@ function loadGallery(images, idx, main, thumbnails) { } }) - function updateGallery(index) { + function updateGallery(index, init) { mainImage.src = images[index].src.replace('_display', '_thumbnail'); setTimeout(() => { mainImage.src = images[index].src; @@ -253,10 +253,12 @@ function loadGallery(images, idx, main, thumbnails) { } prevBtn.disabled = index === 0; nextBtn.disabled = index === images.length - 1; - if (idx == 'inline') { - document.location.hash = `#${index + 1}` - } else { - document.location.hash = `#${idx + 1}/${index + 1}` + if (!init) { + if (idx == 'inline') { + document.location.hash = `#${index + 1}` + } else { + document.location.hash = `#${idx + 1}/${index + 1}` + } } } @@ -299,7 +301,7 @@ function loadGallery(images, idx, main, thumbnails) { }; idx != 'inline' && createThumbnails(); - updateGallery(currentIndex); + updateGallery(currentIndex, true); const imagesIndex = images.map(img => img.src); return {