From 4e696f2adb5de77793ed082280f4d0a173b5c6dc Mon Sep 17 00:00:00 2001 From: zzossig Date: Sun, 12 Jan 2020 23:31:32 +0900 Subject: [PATCH] gallery keyboard bug fixed --- layouts/partials/body/photoswipe.html | 9 +++++++-- layouts/partials/script/gallery-script.html | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/layouts/partials/body/photoswipe.html b/layouts/partials/body/photoswipe.html index 7ffefca..4f826a8 100644 --- a/layouts/partials/body/photoswipe.html +++ b/layouts/partials/body/photoswipe.html @@ -87,6 +87,7 @@ document.addEventListener('DOMContentLoaded', function () { } } + var modal = document.getElementById('modal'); var singleContentsElem = document.querySelector('.single__contents'); var swipeWrapElem = document.querySelector('.swipe-wrap'); var mySwipeElem = document.getElementById('mySwipe'); @@ -103,9 +104,13 @@ document.addEventListener('DOMContentLoaded', function () { var mySwipe = null; var keydownFunction = function (e) { if (e.key === 'ArrowRight') { - mySwipe.next(); + if (modal && modal.classList.contains('is-open')) { + mySwipe.next(); + } } else if (e.key === 'ArrowLeft') { - mySwipe.prev(); + if (modal && modal.classList.contains('is-open')) { + mySwipe.prev(); + } } } diff --git a/layouts/partials/script/gallery-script.html b/layouts/partials/script/gallery-script.html index 2ca75bd..081fbe4 100644 --- a/layouts/partials/script/gallery-script.html +++ b/layouts/partials/script/gallery-script.html @@ -29,7 +29,6 @@ e.target.parentNode.previousElementSibling.click(); } elem.querySelector('.grid-item__desc').onclick = function(e) { - console.log('eee'); e.target.previousElementSibling.click(); } });