|
|
|
|
|
document.addEventListener('DOMContentLoaded', () => { |
|
|
|
|
|
if (localStorage.getItem('theme') === 'light' || (!localStorage.getItem('theme') && window.matchMedia('(prefers-color-scheme: light)').matches)) { |
|
|
document.documentElement.classList.remove('dark'); |
|
|
} else { |
|
|
document.documentElement.classList.add('dark'); |
|
|
} |
|
|
|
|
|
|
|
|
const animateOnScroll = () => { |
|
|
const elements = document.querySelectorAll('.fade-in'); |
|
|
elements.forEach(el => { |
|
|
const elementPosition = el.getBoundingClientRect().top; |
|
|
const screenPosition = window.innerHeight / 1.2; |
|
|
|
|
|
if (elementPosition < screenPosition) { |
|
|
el.style.opacity = '1'; |
|
|
el.style.transform = 'translateY(0)'; |
|
|
} |
|
|
}); |
|
|
}; |
|
|
|
|
|
window.addEventListener('scroll', animateOnScroll); |
|
|
animateOnScroll(); |
|
|
}); |
|
|
|
|
|
|
|
|
function smoothScrollTo(target) { |
|
|
document.querySelector(target).scrollIntoView({ |
|
|
behavior: 'smooth' |
|
|
}); |
|
|
} |