-
Notifications
You must be signed in to change notification settings - Fork 0
/
scriptPopup.js
35 lines (28 loc) · 1023 Bytes
/
scriptPopup.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
30
31
32
33
34
35
// Popup navigation bar for small screens
const hamburger = document.querySelector('.hamburger');
const popupWrapper = document.querySelector('.popup-wrapper');
const popupClose = document.querySelector('.close');
hamburger.addEventListener('click', () => {
popupWrapper.style.display = "block";
popupClose.style.display = "block";
// hamburger.src = 'images/cross.png';
});
popupClose.addEventListener('click', () => {
popupWrapper.style.display = "none";
popupClose.style.display = "none";
});
popupWrapper.addEventListener('click', (event) => {
event.stopPropagation();
popupWrapper.style.display = "none";
popupClose.style.display = "none";
});
// To hide the popup navbar if the screen viewport is changed
function myFunction(x) {
if (x.matches) { // If media query matches
popupWrapper.style.display = "none";
popupClose.style.display = "none";
}
}
var x = window.matchMedia("(min-width: 500px)");
myFunction(x);
x.addListener(myFunction);