fn

useElementByPoint

v0.0.14testeddemo

Reactive element(s) at a given viewport point, sampled every animation frame via document.elementFromPoint (or elementsFromPoint when multiple is set).

Examples

ts
const { x, y } = useMouse();
const { element } = useElementByPoint({ x, y });
ts
const { element } = useElementByPoint({ x, y, multiple: true });

Demo

Loading demo…

Signature

ts
export function useElementByPoint<Multiple extends boolean = false>(
  options: UseElementByPointOptions<Multiple>,
): UseElementByPointReturn<Multiple>{ ... }

Type Parameters

Multipleextends boolean= false

Parameters

ParameterTypeDescription
optionsUseElementByPointOptions<Multiple>Probe coordinates and behaviour

Returns

UseElementByPointReturn<Multiple>{ element, isSupported, pause, resume, toggle }
PropertyTypeDescription
isSupportedComputedRef<boolean>Whether the underlying elementFromPoint / elementsFromPoint API is available (SSR-safe).
elementShallowRef<UseElementByPointValue<Multiple>>The element(s) currently located at the configured point. Updated on every animation frame while active.