-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
36 lines (29 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
34
35
36
const navToggle = document.querySelector(".nav__toggle"),
navMenu = document.querySelector(".nav__menu"),
navClose = document.querySelector(".nav__close"),
navItem = document.querySelectorAll(".nav__item"),
darkMode = document.querySelector(".uil-moon"),
header = document.querySelector(".header");
navToggle.addEventListener("click", () => {
navMenu.classList.add("show-menu");
});
navClose.addEventListener("click", () => {
navMenu.classList.remove("show-menu");
});
navItem.forEach((item) => {
item.addEventListener("click", () => {
navMenu.classList.remove("show-menu");
});
});
darkMode.addEventListener("click", () => {
document.body.classList.toggle("light-theme");
});
window.addEventListener("scroll", () => {
if (window.pageYOffset > 0) {
header.classList.add("shadow");
}
else {
header.classList.remove("shadow");
header.style.transition = ".4s";
};
});