Files
chaffe-theme/src/js/app.js
2025-05-07 16:26:18 -07:00

28 lines
850 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
const el = entry.target;
if (entry.isIntersecting) {
if (!el._hasEnteredOnce) {
// First time in viewport apply delay
el._inViewportTimeout = setTimeout(() => {
el.classList.add('visible');
el._hasEnteredOnce = true;
}, 250);
} else {
// Already entered once no delay
el.classList.add('visible');
}
} else {
clearTimeout(entry.target._inViewportTimeout);
entry.target.classList.remove('visible');
}
});
}, {
threshold: 0.5 // adjust as needed
});
document.querySelectorAll('.watch-vp').forEach(el => {
observer.observe(el);
});