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

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

Paramètres d'entrée acceptés par cet util.

element
requis
IBox | DOMRect
A bounding-box descriptor (IBox) or a native DOMRect. When falsy, both returned coordinates are 0.

API

Valeur de retour

La valeur retournée par cet util.

An object { x, y } representing the centre of the element in the same coordinate space as the input.

Usage

Exemples

Extraits de code prêts à coller.

Centre of a DOMRect

typescript