From a14e1681904c5771609be808ee3fcbe00660b013 Mon Sep 17 00:00:00 2001 From: John B Date: Sat, 16 May 2026 22:52:30 +0300 Subject: [PATCH 1/2] Fix: enable seamless next page loading during lightGallery sliding, add intelligent loop --- app/public/web.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/public/web.js b/app/public/web.js index 3db4ed6..04f7129 100644 --- a/app/public/web.js +++ b/app/public/web.js @@ -16,6 +16,7 @@ class LGallery { this.lightGallery = lightGallery(this.element, Object.assign({ plugins: [lgZoom, lgThumbnail, lgVideo, lgFullscreen, lgHash], speed: 500, + loop: params.items.length <= PER_PAGE, /* This license key was graciously provided by LightGallery under their GPLv3 open-source project license: @@ -34,14 +35,23 @@ class LGallery { this.items = params.items const spinner = document.getElementById('loading-spinner') + let observer = null + if (spinner) { - const observer = new IntersectionObserver((entries) => { + observer = new IntersectionObserver((entries) => { if (entries[0].isIntersecting) { lgallery.loadMoreItems(observer, spinner) } }, { rootMargin: '200px' }) observer.observe(spinner) } + + const preloadThreshold = 8 + this.element.addEventListener('lgAfterSlide', (event) => { + if (event.detail.index >= this.index - preloadThreshold) { + lgallery.loadMoreItems(observer, spinner) + } + }) } /** @@ -60,9 +70,9 @@ class LGallery { this.lightGallery.refresh() } else { // Remove the loading spinner and stop observing once all items are loaded - observer.disconnect() - spinner.remove() + if (observer) observer.disconnect() + if (spinner) spinner.remove() } } } -const lgallery = new LGallery() +const lgallery = new LGallery() \ No newline at end of file From 9a6740ab96db4daa9cc50c3392dc749edc4e9bb2 Mon Sep 17 00:00:00 2001 From: John B Date: Tue, 26 May 2026 22:53:35 +0300 Subject: [PATCH 2/2] PhotoSwipe lightbox options: customization --- README.md | 1 + app/public/web.js | 10 +++++++--- app/src/render.ts | 3 ++- app/src/views/gallery.tsx | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4fe6026..226574d 100644 --- a/README.md +++ b/README.md @@ -220,6 +220,7 @@ The gallery's lightbox is powered by [PhotoSwipe](https://photoswipe.com/). Conf | `showArrows` | `bool` | Show the prev/next arrows on desktop. They appear when the user hovers the lightbox. Default `true`. | | `showDownload` | `bool` | Show a download button in the lightbox toolbar. Only takes effect when downloads are also allowed by `allowDownloadAll`. Default `true`. | | `mobileArrows` | `bool` | Show prev/next arrows on mobile (under 640px viewport). Off by default since swipe is the natural mobile navigation. | +| `options` | `object` | Custom [PhotoSwipe options](https://photoswipe.com/options/) to override defaults (e.g. `{"wheelToZoom": true}`). | Example: hide the download button inside the lightbox even though zip downloads are otherwise allowed: diff --git a/app/public/web.js b/app/public/web.js index 4d992e2..3c4985f 100644 --- a/app/public/web.js +++ b/app/public/web.js @@ -37,6 +37,7 @@ import { thumbHashToDataURL } from '/share/static/thumbhash/thumbhash.js' * @property {boolean} [showArrows] * @property {boolean} [showDownload] * @property {boolean} [mobileArrows] + * @property {Record} [options] */ /** @@ -667,15 +668,18 @@ function buildDataSource () { } function initLightbox () { + const { options = {} } = lightboxConfig; + lightbox = new PhotoSwipeLightbox({ - dataSource: buildDataSource(), - pswpModule: () => import('/share/static/photoswipe/photoswipe.esm.js'), bgOpacity: 1, showHideAnimationType: 'fade', closeOnVerticalDrag: true, arrowKeys: true, loop: false, - padding: { top: 56, bottom: 56, left: 16, right: 16 } + padding: { top: 56, bottom: 56, left: 16, right: 16 }, + ...options, + dataSource: buildDataSource(), + pswpModule: () => import('/share/static/photoswipe/photoswipe.esm.js') }) // Download button (only registered if config enables it) diff --git a/app/src/render.ts b/app/src/render.ts index a22af72..4409b7a 100644 --- a/app/src/render.ts +++ b/app/src/render.ts @@ -179,7 +179,8 @@ class Render { // Show download button only if downloading is allowed AND configured. showDownload: downloadAllowed && !!getConfigOption('ipp.lightbox.showDownload', true), showArrows: !!getConfigOption('ipp.lightbox.showArrows', true), - mobileArrows: !!getConfigOption('ipp.lightbox.mobileArrows', false) + mobileArrows: !!getConfigOption('ipp.lightbox.mobileArrows', false), + options: getConfigOption('ipp.lightbox.options', {}) as Record }, groupByDate } diff --git a/app/src/views/gallery.tsx b/app/src/views/gallery.tsx index b52d9e4..a982f65 100644 --- a/app/src/views/gallery.tsx +++ b/app/src/views/gallery.tsx @@ -27,6 +27,7 @@ export interface LightboxConfig { showArrows: boolean showDownload: boolean mobileArrows: boolean + options?: Record } export interface GalleryProps {