Spaces:
Running
Running
File size: 901 Bytes
e128622 1bff8ca e128622 1bff8ca e128622 1bff8ca e128622 1bff8ca e128622 1bff8ca |
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 |
// Theme toggle
const toggleBtn = document.getElementById('themeToggleBtn');
const html = document.documentElement;
const currentTheme = html.getAttribute('data-theme');
function updateButtonText(theme) {
toggleBtn.textContent = theme === 'dark' ? 'Light' : 'Dark';
}
// Initialize
updateButtonText(currentTheme);
toggleBtn.addEventListener('click', () => {
const newTheme = html.getAttribute('data-theme') === 'dark' ? 'light' : 'dark';
html.setAttribute('data-theme', newTheme);
updateButtonText(newTheme);
});
// Intersection Observer for fade-ins
const observer = new IntersectionObserver(
(entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in');
observer.unobserve(entry.target);
}
});
},
{ threshold: 0.2 }
);
document.querySelectorAll('gallery-item').forEach(el => observer.observe(el)); |