-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom.js
More file actions
31 lines (22 loc) · 777 Bytes
/
custom.js
File metadata and controls
31 lines (22 loc) · 777 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
29
30
function mycolor() {
document.body.classList.toggle("dark_mode");
var isDarkModeEnabled = document.body.classList.contains("dark_mode");
localStorage.setItem("dark_mode", isDarkModeEnabled);
}
document.addEventListener("DOMContentLoaded", function () {
var isDarkModeEnabled = JSON.parse(localStorage.getItem("dark_mode"));
if (isDarkModeEnabled) {
document.body.classList.add("dark_mode");
}
});
const observer = new IntersectionObserver((entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
entry.target.classList.add('show');
} else {
entry.target.classList.remove('show');
}
});
});
const hiddenElements = document.querySelectorAll('.hidden');
hiddenElements.forEach((el) => observer.observe(el));