-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
26 lines (22 loc) · 835 Bytes
/
main.js
File metadata and controls
26 lines (22 loc) · 835 Bytes
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
const nav = document.querySelector('nav');
const mobileNav = document.querySelector('nav.mobile-nav');
const menuIcon = document.querySelector('.menu-icon');
const closeIcon = document.querySelector('.mobile-menu-container .close-icon');
const mobileMenuContainer = document.querySelector('.mobile-menu-container');
function scrolled () {
if (window.scrollY > 70) {
nav.classList.add('scrolled');
mobileNav.classList.add('scrolled')
} else {
nav.classList.remove('scrolled')
mobileNav.classList.remove('scrolled')
}
};
window.addEventListener('scroll', scrolled);
menuIcon.addEventListener('click', () => {
mobileMenuContainer.classList.add("active");
console.log('clicked');
});
closeIcon.addEventListener('click', () => {
mobileMenuContainer.classList.remove("active");
});