-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.js
27 lines (24 loc) · 797 Bytes
/
menu.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
let isMenuOpen = false;
const menuList = document.querySelector('.js-menu');
const menuButton = document.querySelector('.js-menu-button');
let menuButtonHtml = menuButton.innerHTML;
const body = document.querySelector('body');
menuButton.addEventListener('click', toggleMenu);
const header = document.querySelector('.js-header');
function toggleMenu()
{
isMenuOpen = !isMenuOpen;
if(isMenuOpen)
{
menuButton.classList.add('mobile-menu-open');
menuList.classList.add('menu-visible');
body.classList.add('no-scroll');
}
else
{
menuButton.classList.remove('mobile-menu-open');
menuList.classList.remove('menu-visible');
body.classList.remove('no-scroll');
}
menuButton.setAttribute('aria-expanded', isMenuOpen);
}