parts-store/assets/anim.js

9 lines
529 B
JavaScript

// anim.js — scroll-reveal: elements with .reveal fade/slide in as they enter the viewport.
const io = new IntersectionObserver((entries) => {
for (const e of entries) if (e.isIntersecting) { e.target.classList.add('in'); io.unobserve(e.target); }
}, { threshold: 0.12, rootMargin: '0px 0px -8% 0px' });
function watch() { document.querySelectorAll('.reveal:not(.in)').forEach((el) => io.observe(el)); }
watch();
// re-scan when the catalog injects cards
window.addEventListener('catalog:rendered', watch);
export { watch };