forked from Ananyakumar186/dscjnnce
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (21 loc) · 887 Bytes
/
index.js
File metadata and controls
28 lines (21 loc) · 887 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
27
28
// burger-logo, main-ul and .active-nav-mobile classes are defined in the css file
const mobileNav = () => {
const getBurger = document.querySelector(".burger-logo") // get the burger-logo class from the css file
// console.log(getBurger);
const navlinks = document.querySelector(".main-ul"); // get the main-ul class from the css file
// console.log(navlinks);
// The below code makes the class .active-nav-mobile to be visible on the mobile screen
getBurger.addEventListener('click', () => {
navlinks.classList.toggle('activate-nav-mobile');
getBurger.classList.toggle('cross');
})
}
mobileNav();
window.addEventListener('scroll', (e) => {
const nav = document.querySelector('.main-nav');
if (window.pageYOffset > 0) {
nav.classList.add("add-shadow");
} else {
nav.classList.remove("add-shadow");
}
});