getEventCoordinates

Commons
stable

Extracts {clientX, clientY} from a MouseEvent or TouchEvent in a unified way. For touch events, the coordinates of the first touch point are returned.

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 pointer event. Touch events use e.touches[0]; mouse events use e.clientX / e.clientY directly.

API

Valeur de retour

La valeur retournée par cet util.

Object with clientX and clientY in viewport pixels, normalised across mouse and touch input.

Usage

Exemples

Extraits de code prêts à coller.

Normalise pointer position

typescript