2022-04-01 01:02:08 +00:00
|
|
|
<template>
|
2022-04-24 08:05:36 +00:00
|
|
|
<div class="observer" style="height: 1px" />
|
2022-04-01 01:02:08 +00:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: ["options"],
|
|
|
|
data: () => ({
|
|
|
|
observer: null,
|
|
|
|
}),
|
|
|
|
mounted() {
|
2022-04-24 08:05:36 +00:00
|
|
|
const options = this.options || { threshold: 0.0 };
|
2022-04-01 01:02:08 +00:00
|
|
|
this.observer = new IntersectionObserver(([entry]) => {
|
|
|
|
if (entry && entry.isIntersecting) {
|
|
|
|
this.$emit("intersect");
|
|
|
|
}
|
|
|
|
}, options);
|
|
|
|
|
|
|
|
this.observer.observe(this.$el);
|
|
|
|
},
|
|
|
|
destroyed() {
|
|
|
|
this.observer.disconnect();
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|