getPosition

Commons
stable

Extracts a named client coordinate (e.g. clientX, pageY) from a MouseEvent or TouchEvent in a unified way, handling both touch and pointer events transparently.

API

Signature

Signature TypeScript complète, extraite du fichier util.

typescript

API

Paramètres

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

e
requis
MouseEvent | TouchEvent
The native DOM event. Touch events are read via e.touches[0] (or changedTouches[0] for touchend); mouse events are read directly.
position
requis
TClientPosition
The coordinate key to read, e.g. "clientX", "clientY", "pageX", "pageY", "screenX", "screenY".

API

Valeur de retour

La valeur retournée par cet util.

The numeric coordinate value in pixels from the requested position property.

Usage

Exemples

Extraits de code prêts à coller.

Unified pointer coordinate from mouse or touch

typescript