From 72888b4814cc97ce9853832b976cefdcc0f7ad99 Mon Sep 17 00:00:00 2001 From: Khsmty Date: Sun, 26 Feb 2023 12:25:27 +0900 Subject: [PATCH] =?UTF-8?q?enhance(client):=20photoswipe=20=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E6=99=82=E3=81=AB=E6=88=BB=E3=82=8B=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E3=82=92=E3=81=97=E3=81=A6=E3=82=82=E5=89=8D=E3=81=AE=E7=94=BB?= =?UTF-8?q?=E9=9D=A2=E3=81=AB=E6=88=BB=E3=82=89=E3=81=AA=E3=81=84=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=20(#10098)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * enhance(client): photoswipe 表示時に戻る操作をしても前の画面に戻らないように * add: changelog --------- Co-authored-by: syuilo --- CHANGELOG.md | 1 + .../frontend/src/components/MkMediaList.vue | 17 +++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 489fcff2cd..5ac696c28c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### Improvements - feat: 検索画面の統合 (Khsmty) +- photoswipe 表示時に戻る操作をしても前の画面に戻らないように ### Bugfixes - diff --git a/packages/frontend/src/components/MkMediaList.vue b/packages/frontend/src/components/MkMediaList.vue index a12bb78e35..fafa0bd232 100644 --- a/packages/frontend/src/components/MkMediaList.vue +++ b/packages/frontend/src/components/MkMediaList.vue @@ -113,6 +113,23 @@ onMounted(() => { }); lightbox.init(); + + window.addEventListener('popstate', () => { + if (lightbox.pswp && lightbox.pswp.isOpen === true) { + lightbox.pswp.close(); + return; + } + }); + + lightbox.on('beforeOpen', () => { + history.pushState(null, '', '#pswp'); + }); + + lightbox.on('close', () => { + if (window.location.hash === '#pswp') { + history.back(); + } + }); }); const previewable = (file: misskey.entities.DriveFile): boolean => {