Skip to content

Commit 466823c

Browse files
authored
feat(useElementVisibility): inherit rootMargin from useIntersectionObserver (#5207)
1 parent 53abedf commit 466823c

File tree

1 file changed

+3
-7
lines changed
  • packages/core/useElementVisibility

1 file changed

+3
-7
lines changed

packages/core/useElementVisibility/index.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@ import type { ConfigurableWindow } from '../_configurable'
33
import type { MaybeComputedElementRef } from '../unrefElement'
44
import type { UseIntersectionObserverOptions } from '../useIntersectionObserver'
55
import { watchOnce } from '@vueuse/shared'
6-
import { shallowRef, toValue } from 'vue'
6+
import { shallowRef } from 'vue'
77
import { defaultWindow } from '../_configurable'
88
import { useIntersectionObserver } from '../useIntersectionObserver'
99

10-
export interface UseElementVisibilityOptions extends ConfigurableWindow, Pick<UseIntersectionObserverOptions, 'threshold'> {
10+
export interface UseElementVisibilityOptions extends ConfigurableWindow, Pick<UseIntersectionObserverOptions, 'rootMargin' | 'threshold'> {
1111
/**
1212
* Initial value.
1313
*
1414
* @default false
1515
*/
1616
initialValue?: boolean
17-
/**
18-
* @see https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin
19-
*/
20-
rootMargin?: MaybeRefOrGetter<string>
2117
/**
2218
* The element that is used as the viewport for checking visibility of the target.
2319
*/
@@ -74,7 +70,7 @@ export function useElementVisibility(
7470
root: scrollTarget,
7571
window,
7672
threshold,
77-
rootMargin: toValue(rootMargin),
73+
rootMargin,
7874
},
7975
)
8076

0 commit comments

Comments
 (0)