bcabb2ad2d
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
27 lines
694 B
JavaScript
27 lines
694 B
JavaScript
let observer = null;
|
|
|
|
export function init() {
|
|
const items = document.querySelectorAll('[data-reveal]');
|
|
|
|
if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
|
items.forEach((el) => el.classList.add('in'));
|
|
return;
|
|
}
|
|
|
|
observer = new IntersectionObserver((entries) => {
|
|
entries.forEach((entry) => {
|
|
if (entry.isIntersecting) {
|
|
entry.target.classList.add('in');
|
|
observer.unobserve(entry.target);
|
|
}
|
|
});
|
|
}, { rootMargin: '0px 0px -8% 0px' });
|
|
|
|
items.forEach((el) => observer.observe(el));
|
|
}
|
|
|
|
export function destroy() {
|
|
observer?.disconnect();
|
|
observer = null;
|
|
}
|