fix: import type Ref and provide emit

This commit is contained in:
Michael Brevard 2024-03-24 23:15:02 +02:00 committed by GitHub
parent 2ac2a975e0
commit d94436b9c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,6 +1,8 @@
import { defineComponent, onMounted, onUnmounted, ref } from 'vue' import { defineComponent, onMounted, onUnmounted, ref } from 'vue'
import type { Ref } from "vue"
export default defineComponent({ export default defineComponent({
emits: ['intersect'],
setup (props, { emit }) { setup (props, { emit }) {
const intersectionTarget: Ref<Element | null> = ref(null) const intersectionTarget: Ref<Element | null> = ref(null)
let observer: IntersectionObserver | null = null let observer: IntersectionObserver | null = null
@ -9,7 +11,7 @@ export default defineComponent({
entries.forEach((entry) => { entries.forEach((entry) => {
if (entry.isIntersecting) { if (entry.isIntersecting) {
emit('intersect') emit('intersect')
observer.unobserve(entry.target) observer!.unobserve(entry.target)
} }
}) })
} }