-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
54 lines (39 loc) · 1.55 KB
/
script.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
let body=document.querySelector("body")
let mainMenuOpenButton=document.querySelector(".menu__button")
let mainMenuCloseButton=document.querySelector(".menu__cancel")
let overlay=document.querySelector(".overlay")
let mainMenuItems=document.querySelector(".menu__items")
let featureSubmenuButton=document.querySelector(".feature__button")
let companySubmenuButton=document.querySelector(".company__button")
let featureSubmenuItems=document.querySelector(".menu__feature__items")
let companySubmenuItems=document.querySelector(".menu__company__items")
let menuSubItems=document.querySelectorAll(".menu__items__select")
mainMenuOpenButton.addEventListener("click",openMainMenu)
mainMenuCloseButton.addEventListener("click",closeMainMenu)
featureSubmenuButton.addEventListener("click",featureSubmenu)
companySubmenuButton.addEventListener("click",companySubmenu)
menuSubItems.forEach(a=>{
if(window.outerWidth<800)
{
a.addEventListener("click",closeMainMenu)
}
})
function openMainMenu(){
mainMenuItems.style.display="block"
overlay.style.display="block"
body.style.overflow="hidden"
document.documentElement.scrollTop=0
}
function closeMainMenu(){
mainMenuItems.style.display="none"
overlay.style.display="none"
body.style.overflow="auto"
}
function featureSubmenu(){
featureSubmenuItems.classList.toggle("menu__submenu");
featureSubmenuButton.classList.toggle("opened")
}
function companySubmenu(){
companySubmenuItems.classList.toggle("menu__submenu");
companySubmenuButton.classList.toggle("opened")
}