mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-14 01:53:55 +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({
|
export default defineComponent({
|
||||||
setup (props, { emit }) {
|
setup (props, { emit }) {
|
||||||
const intersectionTarget = ref(null)
|
const intersectionTarget: Ref<Element | null> = ref(null)
|
||||||
let observer: IntersectionObserver | null = null
|
let observer: IntersectionObserver | null = null
|
||||||
|
|
||||||
const intersectionCallback = (entries) => {
|
const intersectionCallback: IntersectionObserverCallback = (entries) => {
|
||||||
entries.forEach((entry) => {
|
entries.forEach((entry) => {
|
||||||
if (entry.isIntersecting) {
|
if (entry.isIntersecting) {
|
||||||
emit('intersect')
|
emit('intersect')
|
||||||
@ -16,7 +16,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
observer = new IntersectionObserver(intersectionCallback)
|
observer = new IntersectionObserver(intersectionCallback)
|
||||||
observer.observe(intersectionTarget.value)
|
observer.observe(intersectionTarget.value as Element)
|
||||||
})
|
})
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user