34 lines
1023 B
JavaScript
34 lines
1023 B
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 animation on scroll
|
|
const faders = document.querySelectorAll('.fade-in');
|
|
const appearOptions = {
|
|
threshold: 0.3,
|
|
rootMargin: "0px 0px -50px 0px"
|
|
};
|
|
|
|
const appearOnScroll = new IntersectionObserver(function (entries, appearOnScroll) {
|
|
entries.forEach(entry => {
|
|
if (!entry.isIntersecting) {
|
|
return;
|
|
}
|
|
entry.target.classList.add('visible');
|
|
appearOnScroll.unobserve(entry.target);
|
|
});
|
|
}, appearOptions);
|
|
|
|
faders.forEach(fader => {
|
|
appearOnScroll.observe(fader);
|
|
});
|
|
});
|