fix: proper intersection callback type

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

View File

@ -2,10 +2,10 @@ import { defineComponent, onMounted, onUnmounted, ref } from 'vue'
export default defineComponent({
setup (props, { emit }) {
const intersectionTarget = ref(null)
const intersectionTarget: Ref<Element | null> = ref(null)
let observer: IntersectionObserver | null = null
const intersectionCallback = (entries) => {
const intersectionCallback: IntersectionObserverCallback = (entries) => {
entries.forEach((entry) => {
if (entry.isIntersecting) {
emit('intersect')
@ -16,7 +16,7 @@ export default defineComponent({
onMounted(() => {
observer = new IntersectionObserver(intersectionCallback)
observer.observe(intersectionTarget.value)
observer.observe(intersectionTarget.value as Element)
})
onUnmounted(() => {