mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix: proper intersection callback type
This commit is contained in:
parent
cb221ed579
commit
2ac2a975e0
@ -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(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user