mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
[autofix.ci] apply automated fixes
This commit is contained in:
parent
dbdb3fe6a1
commit
d520d347f2
@ -1,6 +1,5 @@
|
|||||||
import { useNuxtApp } from './nuxt'
|
import { useNuxtApp } from './nuxt'
|
||||||
|
|
||||||
|
|
||||||
export function toArray<T> (value: T | T[]): T[] {
|
export function toArray<T> (value: T | T[]): T[] {
|
||||||
return Array.isArray(value) ? value : [value]
|
return Array.isArray(value) ? value : [value]
|
||||||
}
|
}
|
||||||
@ -9,7 +8,7 @@ export type CallbackFn = () => void
|
|||||||
export type ObserveFn = (element: Element, callback: CallbackFn) => () => void
|
export type ObserveFn = (element: Element, callback: CallbackFn) => () => void
|
||||||
|
|
||||||
export function useIntersectionObserver (options?: IntersectionObserverInit): { observe: ObserveFn } {
|
export function useIntersectionObserver (options?: IntersectionObserverInit): { observe: ObserveFn } {
|
||||||
if (import.meta.server) { return {observe: () => () => {}} }
|
if (import.meta.server) { return { observe: () => () => {} } }
|
||||||
|
|
||||||
const nuxtApp = useNuxtApp()
|
const nuxtApp = useNuxtApp()
|
||||||
if (nuxtApp._observer) {
|
if (nuxtApp._observer) {
|
||||||
@ -28,7 +27,7 @@ export function useIntersectionObserver (options?: IntersectionObserverInit): {
|
|||||||
const isVisible = entry.isIntersecting || entry.intersectionRatio > 0
|
const isVisible = entry.isIntersecting || entry.intersectionRatio > 0
|
||||||
if (isVisible && callback) { callback() }
|
if (isVisible && callback) { callback() }
|
||||||
}
|
}
|
||||||
},options)
|
}, options)
|
||||||
}
|
}
|
||||||
callbacks.set(element, callback)
|
callbacks.set(element, callback)
|
||||||
observer.observe(element)
|
observer.observe(element)
|
||||||
|
Loading…
Reference in New Issue
Block a user