mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-08 01:42:38 +00:00
[autofix.ci] apply automated fixes
This commit is contained in:
parent
6a32dc1c9e
commit
932d143688
@ -1,32 +1,32 @@
|
|||||||
import { ref, onMounted, onUnmounted, defineComponent } from 'vue';
|
import { defineComponent, onMounted, onUnmounted, ref } from 'vue'
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
setup(props, { emit }) {
|
setup (props, { emit }) {
|
||||||
const intersectionTarget = ref(null);
|
const intersectionTarget = ref(null)
|
||||||
let observer = null;
|
let observer = null
|
||||||
|
|
||||||
const intersectionCallback = (entries) => {
|
const intersectionCallback = (entries) => {
|
||||||
entries.forEach(entry => {
|
entries.forEach((entry) => {
|
||||||
if (entry.isIntersecting) {
|
if (entry.isIntersecting) {
|
||||||
emit('intersect');
|
emit('intersect')
|
||||||
observer.unobserve(entry.target);
|
observer.unobserve(entry.target)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
observer = new IntersectionObserver(intersectionCallback);
|
observer = new IntersectionObserver(intersectionCallback)
|
||||||
observer.observe(intersectionTarget.value);
|
observer.observe(intersectionTarget.value)
|
||||||
});
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
if (observer) {
|
if (observer) {
|
||||||
observer.disconnect();
|
observer.disconnect()
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
intersectionTarget
|
intersectionTarget
|
||||||
};
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user