File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
packages/motion/src/utils Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -4,9 +4,14 @@ import type { Options } from '@/types/state'
44import { inView } from 'framer-motion/dom'
55import type { MaybeRef } from '@vueuse/core'
66
7+ type InViewOptions = Options [ 'inViewOptions' ]
8+ export interface UseInViewOptions extends Omit < InViewOptions , 'root' > {
9+ root ?: MaybeRef < Element | Document >
10+ }
11+
712export function useInView < T extends Element = any > (
813 domRef : Ref < T | null > ,
9- options ?: MaybeRef < Options [ 'inViewOptions' ] > ,
14+ options ?: MaybeRef < UseInViewOptions > ,
1015) {
1116 const isInView = ref ( false )
1217
@@ -24,7 +29,10 @@ export function useInView<T extends Element = any>(
2429 isInView . value = false
2530 }
2631 }
27- const cleanup = inView ( domRef . value , onEnter , realOptions )
32+ const cleanup = inView ( domRef . value , onEnter , {
33+ ...realOptions ,
34+ root : unref ( realOptions . root ) ,
35+ } )
2836 onCleanup ( ( ) => {
2937 cleanup ( )
3038 } )
You can’t perform that action at this time.
0 commit comments