0
0
Fork 0
mirror of https://github.com/VueTubeApp/VueTube synced 2024-11-22 19:25:16 +00:00
VueTube/NUXT/components/observer.vue

26 lines
502 B
Vue
Raw Normal View History

<template>
2022-04-24 08:05:36 +00:00
<div class="observer" style="height: 1px" />
</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 };
this.observer = new IntersectionObserver(([entry]) => {
if (entry && entry.isIntersecting) {
this.$emit("intersect");
}
}, options);
this.observer.observe(this.$el);
},
destroyed() {
this.observer.disconnect();
},
};
</script>