getCenter
Commons
stable
Returns the geometric centre point {x, y} of a bounding box or DOMRect. Both coordinates are zero when the element is null.
API
Signature
Full TypeScript signature sourced from the util file.
API
Parameters
Input parameters accepted by this util.
- elementrequiredIBox | DOMRect
- A bounding-box descriptor (IBox) or a native DOMRect. When falsy, both returned coordinates are 0.
API
Return value
The value returned by this util.
- An object { x, y } representing the centre of the element in the same coordinate space as the input.
Usage
Examples
Ready-to-paste usage snippets.
Centre of a DOMRect