-
Notifications
You must be signed in to change notification settings - Fork 3
/
script.js
31 lines (23 loc) · 895 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
30
31
const toggleButton = document.getElementById('theme-toggle');
if (localStorage.getItem('theme') === 'dark') {
document.body.classList.add('dark-mode');
toggleButton.checked = true;
}
toggleButton.addEventListener('click', () => {
document.body.classList.toggle('dark-mode');
if (document.body.classList.contains('dark-mode')) {
localStorage.setItem('theme', 'dark');
} else {
localStorage.setItem('theme', 'light');
}
});
let lastScrollTop = 0;
const floatingDock = document.querySelector('.floating-dock-container');
window.addEventListener('scroll', () => {
if (window.scrollY > 100) {
floatingDock.style.display = 'block';
} else {
floatingDock.style.display = 'none';
}
console.log(window.scrollY)
});