-
Notifications
You must be signed in to change notification settings - Fork 0
/
modal.js
29 lines (24 loc) · 904 Bytes
/
modal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Get the modal
var modal = document.getElementById('infoModal');
// Get the button that opens the modal
var btn = document.getElementById("infoModalButton");
// Get the <div> element that closes the modal
var divClose = document.getElementsByClassName("close")[0];
// When the user clicks on the button, open the modal
btn.onclick = function() {
modal.style.display = "flex";
modal.style.animation = "fadein 0.2s linear";
handlePause()
}
// When the user clicks on <span> (x), close the modal
divClose.onclick = function() {
modal.style.animation = "fadeout 0.2s linear";
setTimeout( () => {modal.style.display = "none";}, 175)
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.animation = "fadeout 0.2s linear";
setTimeout( () => {modal.style.display = "none";}, 175)
}
}