Make lightbox full-bleed by default to match Immich
This commit is contained in:
@@ -45,7 +45,11 @@
|
|||||||
color: var(--pswp-icon-color);
|
color: var(--pswp-icon-color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The zoom, counter, and close buttons are suppressed via PhotoSwipe options
|
||||||
|
(counter/zoom/close: false in client/lightbox.ts) so they can be re-enabled
|
||||||
|
through ipp.lightbox.options, rather than being hidden here in CSS. We use a
|
||||||
|
top-left back arrow (registered as `back-button` in client/lightbox-ui.ts)
|
||||||
|
in place of the close button, matching Immich's native asset-viewer. */
|
||||||
|
|
||||||
.pswp__button--download-button {
|
.pswp__button--download-button {
|
||||||
color: #fff;
|
color: #fff;
|
||||||
|
|||||||
@@ -82,14 +82,24 @@ 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
|
// Pull `padding` out as an override. Drop any `paddingFn` coming from config
|
||||||
const { padding, paddingFn: _ignoredPaddingFn, ...restOptions } = options as any
|
// without overwriting ours: PhotoSwipe expects a function there, so an object
|
||||||
|
// from JSON would crash it.
|
||||||
|
const configPadding = options.padding as Partial<Record<'top' | 'bottom' | 'left' | 'right', number>> | undefined
|
||||||
|
const restOptions = { ...options }
|
||||||
|
delete restOptions.padding
|
||||||
|
delete restOptions.paddingFn
|
||||||
|
|
||||||
|
// Full-bleed by default, the same as Immich. Reserve a bottom strip only when captions
|
||||||
|
// are enabled, so the caption has somewhere to sit without overlapping the image.
|
||||||
|
// Operators can override these via ipp.lightbox.options.padding
|
||||||
|
const showCaption = !!state.metadataConfig.descriptionInCaption
|
||||||
const basePadding = {
|
const basePadding = {
|
||||||
top: padding?.top ?? 56,
|
top: 0,
|
||||||
bottom: padding?.bottom ?? 56,
|
bottom: showCaption ? 56 : 0,
|
||||||
left: padding?.left ?? 16,
|
left: 0,
|
||||||
right: padding?.right ?? 16
|
right: 0,
|
||||||
|
...configPadding
|
||||||
}
|
}
|
||||||
|
|
||||||
state.lightbox = new PhotoSwipeLightbox({
|
state.lightbox = new PhotoSwipeLightbox({
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ Example: show the gallery title and group photos by month.
|
|||||||
The gallery's lightbox is powered by [PhotoSwipe](https://photoswipe.com/). Configured under `ipp.lightbox`.
|
The gallery's lightbox is powered by [PhotoSwipe](https://photoswipe.com/). Configured under `ipp.lightbox`.
|
||||||
|
|
||||||
| Option | Type | Description |
|
| Option | Type | Description |
|
||||||
|----------------|----------|------------------------------------------------------------------------------------------------------------------------------------------|
|
|------------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `showArrows` | `bool` | Show the prev/next arrows on desktop. They appear when the user hovers the lightbox. Default `true`. |
|
| `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`. |
|
| `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. |
|
| `mobileArrows` | `bool` | Show prev/next arrows on mobile (under 640px viewport). Off by default since swipe is the natural mobile navigation. |
|
||||||
|
|||||||
Reference in New Issue
Block a user