Merge pull request #251 from e1jo/fix-lightbox-options-does-not-respond-to-config

Fix PhotoSwipe lightbox configuration for better customization
This commit is contained in:
Alan Grainger
2026-06-14 09:38:52 +12:00
committed by GitHub
2 changed files with 18 additions and 18 deletions
+1 -12
View File
@@ -15,12 +15,6 @@
--pswp-transition-duration: 250ms; --pswp-transition-duration: 250ms;
} }
/* Hide UI Immich doesn't show */
.pswp__button--zoom,
.pswp__counter {
display: none !important;
}
/* Top toolbar: subtle dark backdrop, no shadows */ /* Top toolbar: subtle dark backdrop, no shadows */
.pswp__top-bar { .pswp__top-bar {
background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent); background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent);
@@ -51,12 +45,7 @@
color: var(--pswp-icon-color); color: var(--pswp-icon-color);
} }
/* Hide PhotoSwipe's default top-right X close button - we use a top-left
back arrow instead (registered as `back-button` in client/lightbox-ui.ts),
matching Immich's native asset-viewer affordance. */
.pswp__button--close {
display: none;
}
.pswp__button--download-button { .pswp__button--download-button {
color: #fff; color: #fff;
+17 -6
View File
@@ -82,24 +82,35 @@ function buildDataSource () {
export function initLightbox () { export function initLightbox () {
const { options = {} } = state.lightboxConfig const { options = {} } = state.lightboxConfig
// Extract padding to use as defaults, and paddingFn to avoid overwriting our function with an object from JSON
const { padding, paddingFn: _ignoredPaddingFn, ...restOptions } = options as any
const basePadding = {
top: padding?.top ?? 56,
bottom: padding?.bottom ?? 56,
left: padding?.left ?? 16,
right: padding?.right ?? 16
}
state.lightbox = new PhotoSwipeLightbox({ state.lightbox = new PhotoSwipeLightbox({
bgOpacity: 1, bgOpacity: 1,
showHideAnimationType: 'fade', showHideAnimationType: 'fade',
closeOnVerticalDrag: true, closeOnVerticalDrag: true,
arrowKeys: true, arrowKeys: true,
loop: false, loop: false,
counter: false,
zoom: false,
close: false,
// paddingFn lets the sidebar shrink the slide viewport when open. On a // paddingFn lets the sidebar shrink the slide viewport when open. On a
// narrow viewport the sidebar overlays instead, so we leave padding // narrow viewport the sidebar overlays instead, so we leave padding
// alone in that case. // alone in that case.
paddingFn: () => ({ paddingFn: () => ({
top: 56, ...basePadding,
bottom: 56,
left: 16,
right: state.sidebarOpen && window.innerWidth >= MOBILE_BREAKPOINT right: state.sidebarOpen && window.innerWidth >= MOBILE_BREAKPOINT
? SIDEBAR_WIDTH + 16 ? SIDEBAR_WIDTH + basePadding.right
: 16 : basePadding.right
}), }),
...options, ...restOptions,
dataSource: buildDataSource(), dataSource: buildDataSource(),
// @ts-expect-error - runtime URL resolved by Express static // @ts-expect-error - runtime URL resolved by Express static
pswpModule: () => import('/share/static/photoswipe/photoswipe.esm.js') // eslint-disable-line import/no-absolute-path pswpModule: () => import('/share/static/photoswipe/photoswipe.esm.js') // eslint-disable-line import/no-absolute-path