-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
30 lines (23 loc) · 927 Bytes
/
app.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
//----------------- navigation
const navBtn = document.getElementById("navbar-btn");
const navMenu = document.getElementById("primary-navigation");
navBtn.addEventListener("click", (e) => {
let isOpened = navBtn.getAttribute("aria-expanded") == "true";
if (isOpened) {
navBtn.setAttribute("aria-expanded", "false");
// change button icon to burger
navBtn.querySelector("img").src = "images/icon-menu.svg";
// active overlay
document.getElementById("overlay").classList.toggle("hidden");
// stop page scrolling
document.body.style.overflow = "visible";
} else {
navBtn.setAttribute("aria-expanded", "true");
// change button icon to cross
navBtn.querySelector("img").src = "images/icon-menu-close.svg";
// deactive ovrelay
document.getElementById("overlay").classList.toggle("hidden");
// start page scrolling
document.body.style.overflow = "hidden";
}
});