// Simple IntersectionObserver for scroll animations
document.addEventListener('DOMContentLoaded', () => {
const observerOptions = {
root: null,
rootMargin: '0px',
threshold: 0.1
};
const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('is-visible');
observer.unobserve(entry.target); // Only animate once
}
});
}, observerOptions);
const observeElements = () => {
const elements = document.querySelectorAll('.reveal-on-scroll:not(.observed)');
elements.forEach(el => {
observer.observe(el);
el.classList.add('observed');
});
};
observeElements();
const mutationObserver = new MutationObserver(observeElements);
mutationObserver.observe(document.body, { childList: true, subtree: true });
});