Add typing for Photoswipe options

This commit is contained in:
Alan Grainger
2026-06-14 10:33:10 +12:00
parent 3e6ec97dac
commit 93be4ce9d8
3 changed files with 17 additions and 2 deletions
+11
View File
@@ -31,6 +31,7 @@
"concurrently": "^10.0.3", "concurrently": "^10.0.3",
"eslint": "^8.57.0", "eslint": "^8.57.0",
"eslint-config-standard": "^17.1.0", "eslint-config-standard": "^17.1.0",
"photoswipe": "^5.4.4",
"tsx": "^4", "tsx": "^4",
"typescript": "^5.6.2", "typescript": "^5.6.2",
"vitest": "^4" "vitest": "^4"
@@ -5561,6 +5562,16 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/photoswipe": {
"version": "5.4.4",
"resolved": "https://registry.npmjs.org/photoswipe/-/photoswipe-5.4.4.tgz",
"integrity": "sha512-WNFHoKrkZNnvFFhbHL93WDkW3ifwVOXSW3w1UuZZelSmgXpIGiZSNlZJq37rR8YejqME2rHs9EhH9ZvlvFH2NA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.12.0"
}
},
"node_modules/picocolors": { "node_modules/picocolors": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz",
+1
View File
@@ -40,6 +40,7 @@
"concurrently": "^10.0.3", "concurrently": "^10.0.3",
"eslint": "^8.57.0", "eslint": "^8.57.0",
"eslint-config-standard": "^17.1.0", "eslint-config-standard": "^17.1.0",
"photoswipe": "^5.4.4",
"tsx": "^4", "tsx": "^4",
"typescript": "^5.6.2", "typescript": "^5.6.2",
"vitest": "^4" "vitest": "^4"
+5 -2
View File
@@ -6,6 +6,7 @@
// @ts-expect-error - browser-only ESM URL // @ts-expect-error - browser-only ESM URL
import PhotoSwipeLightbox from '/share/static/photoswipe/photoswipe-lightbox.esm.js' // eslint-disable-line import/no-absolute-path import PhotoSwipeLightbox from '/share/static/photoswipe/photoswipe-lightbox.esm.js' // eslint-disable-line import/no-absolute-path
import type { PhotoSwipeOptions } from 'photoswipe'
import { state, SIDEBAR_WIDTH, MOBILE_BREAKPOINT } from './state.js' import { state, SIDEBAR_WIDTH, MOBILE_BREAKPOINT } from './state.js'
import type { GalleryItem } from '../shared/types.js' import type { GalleryItem } from '../shared/types.js'
import { import {
@@ -95,7 +96,7 @@ export function initLightbox () {
...configPadding ...configPadding
} }
state.lightbox = new PhotoSwipeLightbox({ const lightboxOptions: PhotoSwipeOptions = {
bgOpacity: 1, bgOpacity: 1,
showHideAnimationType: 'fade', showHideAnimationType: 'fade',
closeOnVerticalDrag: true, closeOnVerticalDrag: true,
@@ -122,7 +123,9 @@ export function initLightbox () {
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
}) }
state.lightbox = new PhotoSwipeLightbox(lightboxOptions)
registerBackButton(state.lightbox) registerBackButton(state.lightbox)
if (state.lightboxConfig.showDownload) registerDownloadButton(state.lightbox) if (state.lightboxConfig.showDownload) registerDownloadButton(state.lightbox)