mirror of https://github.com/VueTubeApp/VueTube
26 lines
466 B
Vue
26 lines
466 B
Vue
|
<template>
|
||
|
<div class="observer" />
|
||
|
</template>
|
||
|
|
||
|
<script>
|
||
|
export default {
|
||
|
props: ["options"],
|
||
|
data: () => ({
|
||
|
observer: null,
|
||
|
}),
|
||
|
mounted() {
|
||
|
const options = this.options || {};
|
||
|
this.observer = new IntersectionObserver(([entry]) => {
|
||
|
if (entry && entry.isIntersecting) {
|
||
|
this.$emit("intersect");
|
||
|
}
|
||
|
}, options);
|
||
|
|
||
|
this.observer.observe(this.$el);
|
||
|
},
|
||
|
destroyed() {
|
||
|
this.observer.disconnect();
|
||
|
},
|
||
|
};
|
||
|
</script>
|