-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
39 lines (33 loc) · 1.02 KB
/
main.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
36
37
38
39
const iconMenu = document.querySelector(".mainNav__iconMenu"),
menu = document.querySelector(".mainNav"),
menuItem = document.querySelectorAll(".mainNav__menuItem"),
body = document.querySelector("body");
iconMenu.addEventListener("click", openMenu);
menuItem.forEach(function(el) {
el.addEventListener("mouseover", opacityIn);
el.addEventListener("mouseleave", opacityOut);
});
function openMenu() {
if (menu.classList.contains("menuOpen")) {
menu.classList.add("menuClose");
body.style.overflow ="initial";
setTimeout(function() {
menu.classList.remove("menuClose");
menu.classList.remove("menuOpen");
}, 1200);
} else {
body.style.overflow ="hidden";
menu.classList.add("menuOpen");
}
}
function opacityIn(e) {
menuItem.forEach(function(el) {
el.classList.add("disable");
});
e.currentTarget.classList.remove("disable");
}
function opacityOut() {
menuItem.forEach(function(el) {
el.classList.remove("disable");
});
}