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'
4
4
import { inView } from 'framer-motion/dom'
5
5
import type { MaybeRef } from '@vueuse/core'
6
6
7
+ type InViewOptions = Options [ 'inViewOptions' ]
8
+ export interface UseInViewOptions extends Omit < InViewOptions , 'root' > {
9
+ root ?: MaybeRef < Element | Document >
10
+ }
11
+
7
12
export function useInView < T extends Element = any > (
8
13
domRef : Ref < T | null > ,
9
- options ?: MaybeRef < Options [ 'inViewOptions' ] > ,
14
+ options ?: MaybeRef < UseInViewOptions > ,
10
15
) {
11
16
const isInView = ref ( false )
12
17
@@ -24,7 +29,10 @@ export function useInView<T extends Element = any>(
24
29
isInView . value = false
25
30
}
26
31
}
27
- const cleanup = inView ( domRef . value , onEnter , realOptions )
32
+ const cleanup = inView ( domRef . value , onEnter , {
33
+ ...realOptions ,
34
+ root : unref ( realOptions . root ) ,
35
+ } )
28
36
onCleanup ( ( ) => {
29
37
cleanup ( )
30
38
} )
You can’t perform that action at this time.
0 commit comments