[autofix.ci] apply automated fixes

This commit is contained in:
autofix-ci[bot] 2024-03-24 17:54:31 +00:00 committed by GitHub
parent 6a32dc1c9e
commit 932d143688
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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
};
} }
}); }
})