viewportToElement

Commons
stable

Convert a point expressed in viewport (page) coordinates to the local coordinate space of an element by subtracting the element's bounding-box offset.

API

Signature

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

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

point
requis
TViewportPoint
The { x, y } point in viewport (screen) coordinates, e.g. from a pointer event's clientX/clientY.
offset
requis
TOffset | IBox
The element's bounding box or a plain { x, y } offset (e.g. from getBoundingClientRect()).

API

Valeur de retour

La valeur retournée par cet util.

The { x, y } point in the element's local coordinate space.

Usage

Exemples

Extraits de code prêts à coller.

Translate a click position into element space

typescript