From f3cc4f6fa0f5bfa464759ff7fdb72b1c709cb5ab Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Thu, 6 Mar 2025 19:42:44 +0530 Subject: [PATCH] lp fix if nearby slide --- .../gallery/components/viewer/photoswipe.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/web/packages/gallery/components/viewer/photoswipe.ts b/web/packages/gallery/components/viewer/photoswipe.ts index 3361f5faa0..5ad19eb76e 100644 --- a/web/packages/gallery/components/viewer/photoswipe.ts +++ b/web/packages/gallery/components/viewer/photoswipe.ts @@ -389,10 +389,6 @@ export class FileViewerPhotoSwipe { /** * Update the state of the given `videoElement` and the * `livePhotoToggleButtonElement` to reflect `livePhotoPlay`. - * - * Note that "contentAppend" can get called both before, or after, - * "change", so we need to handle both potential sequences for the - * initial display of the video. */ const livePhotoUpdatePlayback = (video: HTMLVideoElement) => { const button = livePhotoToggleButtonElement; @@ -423,7 +419,7 @@ export class FileViewerPhotoSwipe { }; pswp.on("contentAppend", (e) => { - const { fileType, videoURL } = e.content.data; + const { fileID, fileType, videoURL } = e.content.data; if (fileType !== FileType.livePhoto) return; if (!videoURL) return; @@ -446,7 +442,14 @@ export class FileViewerPhotoSwipe { video.style.width = img.style.width; video.style.height = img.style.height; - livePhotoUpdatePlayback(video); + // "contentAppend" can get called both before, or after, "change", + // and we need to handle both potential sequences for the initial + // display of the video. Here we handle the case where "change" has + // already been called, but now "contentAppend" is happening. + + if (pswp.currSlide.data.fileID == fileID) { + livePhotoUpdatePlayback(video); + } }); /**