43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
// Smooth scrolling for anchor links
|
|
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
|
|
anchor.addEventListener('click', function (e) {
|
|
e.preventDefault();
|
|
|
|
document.querySelector(this.getAttribute('href')).scrollIntoView({
|
|
behavior: 'smooth'
|
|
});
|
|
});
|
|
});
|
|
|
|
// Fade-in animations on scroll
|
|
const observer = new IntersectionObserver((entries) => {
|
|
entries.forEach(entry => {
|
|
if (entry.isIntersecting) {
|
|
entry.target.classList.add('fade-in');
|
|
}
|
|
});
|
|
}, { threshold: 0.1 });
|
|
|
|
document.querySelectorAll('section').forEach(section => {
|
|
section.classList.add('fade-in-hidden');
|
|
observer.observe(section);
|
|
});
|
|
});
|
|
|
|
// Add fade-in CSS
|
|
const style = document.createElement('style');
|
|
style.innerHTML = `
|
|
.fade-in-hidden {
|
|
opacity: 0;
|
|
transform: translateY(20px);
|
|
transition: opacity 0.6s ease-out, transform 0.6s ease-out;
|
|
}
|
|
.fade-in {
|
|
opacity: 1;
|
|
transform: translateY(0);
|
|
}
|
|
`;
|
|
document.head.appendChild(style);
|