fn
useElementByPoint
v0.0.14testeddemoReactive 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= falseParameters
| Parameter | Type | Description |
|---|---|---|
options | UseElementByPointOptions<Multiple> | Probe coordinates and behaviour |
Returns
UseElementByPointReturn<Multiple>{ element, isSupported, pause, resume, toggle }| Property | Type | Description |
|---|---|---|
isSupported | ComputedRef<boolean> | Whether the underlying elementFromPoint / elementsFromPoint API is
available (SSR-safe). |
element | ShallowRef<UseElementByPointValue<Multiple>> | The element(s) currently located at the configured point. Updated on every animation frame while active. |