getLocationOffset

Commons
stable

Computes the cumulative offset of an element from the document edge by walking its offsetParent chain, or returns a raw numeric offset (negated in RTL horizontal mode).

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

target
required
any
A number (returned as-is), a CSS selector string, a Vue component instance, or an HTMLElement. Numbers in horizontal RTL mode are negated.
horizontal
boolean
When true, measures the horizontal (left) offset instead of the vertical (top) offset.
rtl
boolean
When true and horizontal is true, a numeric target is negated to account for RTL document direction.

API

Return value

The value returned by this util.

The cumulative pixel offset of the element from the document edge (top by default, left in horizontal mode).

Usage

Examples

Ready-to-paste usage snippets.

Vertical offset of an element

typescript