mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-03 22:14:10 +00:00
Merge branch 'patch-21' of https://github.com/GalacticHypernova/nuxt into patch-21
This commit is contained in:
commit
52e55ee044
@ -1,5 +1,5 @@
|
||||
import { useNuxtApp } from './nuxt'
|
||||
import defu from 'defu'
|
||||
import { useNuxtApp } from './nuxt'
|
||||
|
||||
/** @since 3.9.0 */
|
||||
export function toArray<T> (value: T | T[]): T[] {
|
||||
@ -10,7 +10,7 @@ export type CallbackFn = () => void
|
||||
export type ObserveFn = (element: Element, callback: CallbackFn) => () => void
|
||||
|
||||
export function useIntersectionObserver (options?: Partial<IntersectionObserverInit>): { observe: ObserveFn } {
|
||||
if (import.meta.server) { return {observe: () => () => {}} }
|
||||
if (import.meta.server) { return { observe: () => () => {} } }
|
||||
|
||||
const nuxtApp = useNuxtApp()
|
||||
if (nuxtApp._observer) {
|
||||
@ -28,7 +28,7 @@ export function useIntersectionObserver (options?: Partial<IntersectionObserverI
|
||||
const isVisible = entry.isIntersecting || entry.intersectionRatio > 0
|
||||
if (isVisible && callback) { callback() }
|
||||
}
|
||||
}, defu(options ?? {},{root: null, rootMargin: "0px", threshold: 0}))
|
||||
}, defu(options ?? {}, { root: null, rootMargin: '0px', threshold: 0 }))
|
||||
}
|
||||
callbacks.set(element, callback)
|
||||
observer.observe(element)
|
||||
|
Loading…
Reference in New Issue
Block a user