-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnav.js
25 lines (23 loc) · 771 Bytes
/
nav.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
const mobileMenu = document.querySelector(".m-menu");
const mobileMenuBtn = document.querySelector(".mobile-menu-btn");
mobileMenuBtn.addEventListener("click", () => {
mobileMenuBtn.classList.toggle("active-menu-btn");
mobileMenu.classList.toggle("slide-out");
mobileMenu.classList.toggle("slide-in");
if (mobileMenu.classList.contains("slide-out")) {
setTimeout(() => {
mobileMenu.classList.add("display-none");
}, 1000);
} else {
mobileMenu.classList.remove("display-none");
}
});
window.addEventListener("resize", () => {
if (window.innerWidth > 750) {
mobileMenu.classList.add("slide-out");
mobileMenu.classList.remove("slide-in");
setTimeout(() => {
mobileMenu.classList.add("display-none");
}, 1000);
}
});