From 4e94a9c19ba50db2dc78fe390fcc3ce6ac293194 Mon Sep 17 00:00:00 2001 From: Dylan Depass Date: Thu, 25 Sep 2025 11:25:30 -0400 Subject: [PATCH 1/2] fix: gallery slide when zoomed --- scripts/scripts.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/scripts.js b/scripts/scripts.js index 6506b7a9..a603885d 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -229,6 +229,7 @@ export function buildCarousel(container, pagination = true) { button.setAttribute('aria-label', `${label} frame`); button.addEventListener('click', () => { const slideWidth = getSlideWidth(carousel); + const zoomLevel = Math.round((window.outerWidth / window.innerWidth) * 100) / 100; const visible = getVisibleSlides(container); const { scrollLeft } = carousel; const current = Math.round(scrollLeft / slideWidth); @@ -237,12 +238,12 @@ export function buildCarousel(container, pagination = true) { if (current <= 0) { // Loop to the end carousel.scrollTo({ - left: (slides.length - visible) * slideWidth, + left: (slides.length - visible) * slideWidth * zoomLevel, behavior: 'smooth', }); } else { carousel.scrollBy({ - left: -slideWidth * visible, + left: -slideWidth * visible * zoomLevel, behavior: 'smooth', }); } @@ -254,7 +255,7 @@ export function buildCarousel(container, pagination = true) { }); } else { carousel.scrollBy({ - left: slideWidth * visible, + left: slideWidth * visible * zoomLevel, behavior: 'smooth', }); } From 9fe3caa62214c847dd6ccd43f350502ac930c50c Mon Sep 17 00:00:00 2001 From: Dylan Depass Date: Thu, 25 Sep 2025 11:59:54 -0400 Subject: [PATCH 2/2] fix: simplify calculation --- scripts/scripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/scripts.js b/scripts/scripts.js index a603885d..481a580b 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -229,7 +229,7 @@ export function buildCarousel(container, pagination = true) { button.setAttribute('aria-label', `${label} frame`); button.addEventListener('click', () => { const slideWidth = getSlideWidth(carousel); - const zoomLevel = Math.round((window.outerWidth / window.innerWidth) * 100) / 100; + const zoomLevel = Number((window.outerWidth / window.innerWidth).toFixed(2)); const visible = getVisibleSlides(container); const { scrollLeft } = carousel; const current = Math.round(scrollLeft / slideWidth);