bindScroll

Commons
stable

Attach a passive scroll listener to the document and all scroll parents of an element. Automatically removes all listeners on Vue scope disposal via onScopeDispose.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

el
required
HTMLElement | undefined
The reference element whose scroll parents are collected. Pass undefined to bind only the document.
onScroll
required
(e: Event) => void
Callback invoked on every scroll event from any of the collected elements.

API

Return value

The value returned by this util.

No return value. Cleanup is automatic via onScopeDispose when called inside a Vue effect scope.

Usage

Examples

Ready-to-paste usage snippets.

Track scroll position in a composable

typescript