21 lines
400 B
JavaScript
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)
|
|
}
|
|
}
|