youtube-ulbi-vue/src/dirictives/VIntersection.js
2025-01-15 07:43:56 +03:00

21 lines
400 B
JavaScript

export default {
name: 'intersection',
mounted(el, binding) {
const { loadMorePost } = binding.value;
const options = {
rootMargin: "0px",
threshold: 1.0,
};
const callback = (entries) => {
if (entries[0].isIntersecting) {
loadMorePost();
}
};
const observer = new IntersectionObserver(callback, options);
observer.observe(el)
}
}