-
Notifications
You must be signed in to change notification settings - Fork 0
/
menu.js
40 lines (35 loc) · 1.12 KB
/
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
28
29
30
31
32
33
34
35
36
37
38
39
40
function makeScrollable() {
const body = document.querySelector('body');
body.classList.remove('makeNotScrollable');
body.classList.add('makeScrollable');
}
function makeNotScrollable() {
const body = document.querySelector('body');
body.classList.remove('makeScrollable');
body.classList.add('makeNotScrollable');
}
function closeMenu() {
const menu = document.querySelector('.menu-options');
menu.classList.remove('visible');
menu.classList.add('invisible');
makeScrollable();
}
const optionsBtn = document.querySelector('.hamburger-button');
optionsBtn.addEventListener('click', () => {
const menu = document.querySelector('.menu-options');
menu.classList.remove('invisible');
menu.classList.add('visible');
makeNotScrollable();
});
const closeOption = document.querySelector('#close-btn');
closeOption.addEventListener('click', () => {
closeMenu();
});
document.addEventListener('click', (e) => {
if (e.target.matches('.menu-options ul li a')) {
const menu = document.querySelector('.menu-options');
menu.classList.remove('visible');
menu.classList.add('invisible');
makeScrollable();
}
});