mirror of
https://iceshrimp.dev/Crimekillz/jointrashposs.git
synced 2024-11-24 17:59:07 +01:00
24 lines
553 B
TypeScript
24 lines
553 B
TypeScript
export const vFadeIn = {
|
|
mounted: (src, binding, vn) => {
|
|
src.classList.add('__v_fadeIn_out');
|
|
src.children[0].style.transition = `all 0.5s ease`;
|
|
|
|
function onIntersect(entries) {
|
|
for (const entry of entries) {
|
|
if (entry.isIntersecting) {
|
|
entry.target.classList.add('__v_fadeIn_in');
|
|
} else {
|
|
entry.target.classList.remove('__v_fadeIn_in');
|
|
}
|
|
}
|
|
}
|
|
|
|
const observer = new IntersectionObserver(onIntersect, {
|
|
root: null,
|
|
rootMargin: '9999px 0px -300px 0px',
|
|
threshold: 0,
|
|
});
|
|
|
|
observer.observe(src);
|
|
}
|
|
}; |