diff --git a/app/public/web.js b/app/public/web.js index ba3b2e5..f7a075e 100644 --- a/app/public/web.js +++ b/app/public/web.js @@ -82,8 +82,10 @@ const HEADER_HEIGHT = 48 // Vertical gap between groups const GROUP_GAP = 16 -// MDI download icon (Apache 2.0). Same icon set Immich uses for its viewer. +// MDI icons (Apache 2.0). Same icon set Immich uses for its viewer. const ICON_DOWNLOAD = '' +const ICON_FULLSCREEN = '' +const ICON_FULLSCREEN_EXIT = '' // ----- module state --------------------------------------------------------- @@ -701,6 +703,42 @@ function initLightbox () { }) } + // Fullscreen toggle. Skipped on browsers without Fullscreen API support + // for arbitrary elements (notably iOS Safari on iPhone). + if (document.fullscreenEnabled) { + lightbox.on('uiRegister', () => { + lightbox.pswp.ui.registerElement({ + name: 'fullscreen-button', + order: 9, + isButton: true, + html: ICON_FULLSCREEN, + onInit: (el, pswp) => { + const update = () => { + const active = document.fullscreenElement === pswp.element + el.innerHTML = active ? ICON_FULLSCREEN_EXIT : ICON_FULLSCREEN + el.setAttribute('aria-label', active ? 'Exit fullscreen' : 'Fullscreen') + el.setAttribute('title', active ? 'Exit fullscreen' : 'Fullscreen') + } + update() + el.addEventListener('click', () => { + if (document.fullscreenElement) { + document.exitFullscreen().catch(() => {}) + } else { + pswp.element.requestFullscreen().catch(() => {}) + } + }) + document.addEventListener('fullscreenchange', update) + pswp.on('destroy', () => { + document.removeEventListener('fullscreenchange', update) + if (document.fullscreenElement === pswp.element) { + document.exitFullscreen().catch(() => {}) + } + }) + } + }) + }) + } + // Caption from EXIF description (only present when item.description is set; // server-side gated on ipp.showMetadata.description). Content is already // HTML-escaped in render.ts, so innerHTML assignment is safe.