Skip to content

Commit 8892ef0

Browse files
authored
Merge branch 'main' into prettier
2 parents bf1bee7 + 21d89e9 commit 8892ef0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

docs/js/Modal.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,21 @@ const scrollbarWidthCssVar = "--pico-scrollbar-width";
1313
const animationDuration = 400; // ms
1414
let visibleModal = null;
1515

16+
1617
// Toggle modal
1718
const toggleModal = (event) => {
1819
event.preventDefault();
1920
const modal = document.getElementById(event.currentTarget.dataset.target);
2021
if (!modal) return;
21-
modal && (modal.open ? closeModal(modal) : openModal(modal));
22+
if (event.currentTarget.dataset.close) {
23+
const modalClose = document.getElementById(event.currentTarget.dataset.close);
24+
if (modalClose) {
25+
closeModal(modalClose);
26+
setTimeout(() => modal && (modal.open ? closeModal(modal) : openModal(modal)), animationDuration);
27+
}
28+
} else {
29+
modal && (modal.open ? closeModal(modal) : openModal(modal));
30+
}
2231
};
2332

2433
// Open modal

0 commit comments

Comments
 (0)