forked from roboticslover/portfolio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
29 lines (23 loc) · 811 Bytes
/
script.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
let header = document.querySelector("header");
let menu = document.querySelector("#menu-icon");
let navbar = document.querySelector(".navbar");
window.addEventListener("scroll", () => {
header.classList.toggle("shadow", window.scrollY > 0);
});
menu.onclick = () => {
navbar.classList.toggle("active");
};
window.onscroll = () => {
navbar.classList.remove("active");
};
// Dark Mode / light mode
let darkmode = document.querySelector("#darkmode");
darkmode.onclick = () => {
if (darkmode.classList.contains("bx-moon")) {
darkmode.classList.replace("bx-moon", "bx-sun");
document.body.classList.add("active");
} else {
darkmode.classList.replace("bx-sun", "bx-moon");
document.body.classList.remove("active");
}
};