techviking-express / script.js
lundstream's picture
Lägg till Körkort
4c4cfbf verified
Raw History Blame Contribute Delete
965 Bytes
// 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'
});
});
});
// Intersection Observer for animations
const animateOnScroll = () => {
const elements = document.querySelectorAll('.animate-on-scroll');
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-fadeIn');
observer.unobserve(entry.target);
}
});
}, {
threshold: 0.1
});
elements.forEach(element => {
observer.observe(element);
});
};
document.addEventListener('DOMContentLoaded', () => {
animateOnScroll();
feather.replace();
});