getScrollParents

Commons
stable

Collects all scrollable ancestor elements of a given element up to an optional boundary, returning them as an array. Used by overlay scroll strategies to block or track all scroll containers at once.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

el
Element | null
The starting element. Returns an empty array when null or undefined.
stopAt
Element | null
An optional boundary element. The walk stops when this element is reached (inclusive). When stopAt does not contain el, an empty array is returned immediately.

API

Return value

The value returned by this util.

An ordered array of scrollable ancestors, from closest to furthest.

Usage

Examples

Ready-to-paste usage snippets.

Block all scroll containers when a dialog opens

typescript