-
Notifications
You must be signed in to change notification settings - Fork 501
/
main.js
33 lines (28 loc) · 959 Bytes
/
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
// Select DOM Items
const menuBtn = document.querySelector('.menu-btn');
const menu = document.querySelector('.menu');
const menuNav = document.querySelector('.menu-nav');
const menuBranding = document.querySelector('.menu-branding');
const navItems = document.querySelectorAll('.nav-item');
// Set Initial State Of Menu
let showMenu = false;
menuBtn.addEventListener('click', toggleMenu);
function toggleMenu() {
if (!showMenu) {
menuBtn.classList.add('close');
menu.classList.add('show');
menuNav.classList.add('show');
menuBranding.classList.add('show');
navItems.forEach(item => item.classList.add('show'));
// Set Menu State
showMenu = true;
} else {
menuBtn.classList.remove('close');
menu.classList.remove('show');
menuNav.classList.remove('show');
menuBranding.classList.remove('show');
navItems.forEach(item => item.classList.remove('show'));
// Set Menu State
showMenu = false;
}
}