From 72888b4814cc97ce9853832b976cefdcc0f7ad99 Mon Sep 17 00:00:00 2001 From: Khsmty Date: Sun, 26 Feb 2023 12:25:27 +0900 Subject: enhance(client): photoswipe 表示時に戻る操作をしても前の画面に戻らないように (#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 + packages/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 => { -- cgit v1.2.3-freya