diff options
author | Volpeon <git@volpeon.ink> | 2022-06-14 20:35:37 +0200 |
---|---|---|
committer | Volpeon <git@volpeon.ink> | 2022-06-14 20:35:37 +0200 |
commit | 7d9bb5fee50561bdce8fe7440ae9d1b8aae48bd0 (patch) | |
tree | d8955670f0bff46eaa06997e84a450143e8e5302 /content/main.js | |
parent | Fix print style bg (diff) | |
download | volpeon.ink-7d9bb5fee50561bdce8fe7440ae9d1b8aae48bd0.tar.gz volpeon.ink-7d9bb5fee50561bdce8fe7440ae9d1b8aae48bd0.tar.bz2 volpeon.ink-7d9bb5fee50561bdce8fe7440ae9d1b8aae48bd0.zip |
Update
Diffstat (limited to 'content/main.js')
-rw-r--r-- | content/main.js | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/content/main.js b/content/main.js index 3257c39..760d40a 100644 --- a/content/main.js +++ b/content/main.js | |||
@@ -22,6 +22,7 @@ | |||
22 | (() => { | 22 | (() => { |
23 | let currentIndex = 0; | 23 | let currentIndex = 0; |
24 | let visible = false; | 24 | let visible = false; |
25 | let mouseDown = false; | ||
25 | 26 | ||
26 | const mainEl = document.querySelector("main"); | 27 | const mainEl = document.querySelector("main"); |
27 | const lightboxContainerEl = document.querySelector(".js-lightbox"); | 28 | const lightboxContainerEl = document.querySelector(".js-lightbox"); |
@@ -90,6 +91,21 @@ | |||
90 | return thumbnailButtonEl; | 91 | return thumbnailButtonEl; |
91 | }); | 92 | }); |
92 | 93 | ||
94 | document.addEventListener('mousedown', (e) => { | ||
95 | if (visible) { | ||
96 | mouseDown = !lightboxEl.contains(e.target) || lightboxEl === e.target; | ||
97 | } | ||
98 | }); | ||
99 | |||
100 | document.addEventListener('click', (e) => { | ||
101 | if (visible && mouseDown) { | ||
102 | mouseDown = false; | ||
103 | e.preventDefault(); | ||
104 | e.stopPropagation(); | ||
105 | hide(); | ||
106 | } | ||
107 | }, { capture: true }); | ||
108 | |||
93 | window.addEventListener("keydown", e => { | 109 | window.addEventListener("keydown", e => { |
94 | if (e.defaultPrevented || !visible) { | 110 | if (e.defaultPrevented || !visible) { |
95 | return; | 111 | return; |