change the visibility of the modal (now in js, not in css)

This commit is contained in:
Matteo Manzinello
2019-05-11 00:28:32 +02:00
parent 16e3729f85
commit 71df7e916a
8 changed files with 17 additions and 25 deletions

View File

@@ -58,6 +58,7 @@ mailgoInit = () => {
// modal
let modal = document.createElement("div");
modal.classList.add("mailgo-modal");
modal.style.display = "none";
modal.setAttribute("data-index", index);
// background
@@ -225,17 +226,17 @@ mailgoInit = () => {
event.preventDefault();
// modal is now active (showing)
mailgo.nextElementSibling.classList.add("is-active");
mailgo.nextElementSibling.style.display = "flex";
},
false
);
// allow the escape key to hide the modal
mailgo.addEventListener(
"keydown",
event => {
if (event.keyCode === 27) {
mailgo.nextElementSibling.classList.remove("is-active");
mailgo.nextElementSibling.style.display = "flex";
}
},
false
@@ -245,7 +246,7 @@ mailgoInit = () => {
modalBackground.addEventListener(
"click",
event => {
mailgo.nextElementSibling.classList.remove("is-active");
mailgo.nextElementSibling.style.display = "none";
},
false
);