MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

Cette traduction est incomplète. Aidez à traduire cet article depuis l'anglais.

The Touch interface represents a single contact point on a touch-sensitive device. The contact point is commonly a finger or stylus and the device may be a touchscreen or trackpad.

The Touch.radiusX, Touch.radiusY, and Touch.rotationAngle describe the area of contact between the user and the screen, the touch area. This can be helpful when dealing with imprecise pointing devices such as fingers. These values are set to describe an ellipse that as closely as possible matches the entire area of contact (such as the user's fingertip).

Note: Many of the properties' values are hardware-dependent; for example, if the device doesn't have a way to detect the amount of pressure placed on the surface, the force value will always be 0. This may also be the case for radiusX and radiusY; if the hardware reports only a single point, these values will be 1.

Constructeur

Touch()
Créer un Objet Touch .

Properties

This interface has no parent, and doesn't inherits or implements any other property.

Basic properties

Touch.identifier Lecture seule
Returns a unique identifier for this Touch object. A given touch point (say, by a finger) will have the same identifier for the duration of its movement around the surface. This lets you ensure that you're tracking the same touch all the time.
Touch.screenX Lecture seule
Returns the X coordinate of the touch point relative to the left edge of the screen.
Touch.screenY Lecture seule
Returns the Y coordinate of the touch point relative to the top edge of the screen.
Touch.clientX Lecture seule
Returns the X coordinate of the touch point relative to the left edge of the browser viewport, not including any scroll offset.
Touch.clientY Lecture seule
Returns the Y coordinate of the touch point relative to the top edge of the browser viewport, not including any scroll offset.
Touch.pageX Lecture seule
Returns the X coordinate of the touch point relative to the left edge of the document. Unlike clientX, this value includes the horizontal scroll offset, if any.
Touch.pageY Lecture seule
Returns the Y coordinate of the touch point relative to the top of the document. Unlike clientY, this value includes the vertical scroll offset, if any.
Touch.target Lecture seule
Returns the Element on which the touch point started when it was first placed on the surface, even if the touch point has since moved outside the interactive area of that element or even been removed from the document.

Touch area

Cette fonction est expérimentale
Puisque cette fonction est toujours en développement dans certains navigateurs, veuillez consulter le tableau de compatibilité pour les préfixes à utiliser selon les navigateurs.
Il convient de noter qu'une fonctionnalité expérimentale peut voir sa syntaxe ou son comportement modifié dans le futur en fonction des évolutions de la spécification.

Touch.radiusX Lecture seule
Returns the X radius of the ellipse that most closely circumscribes the area of contact with the screen. The value is in pixels of the same scale as screenX.
Touch.radiusY Lecture seule
Returns the Y radius of the ellipse that most closely circumscribes the area of contact with the screen. The value is in pixels of the same scale as screenY.
Touch.rotationAngle Lecture seule
Returns the angle (in degrees) that the ellipse described by radiusX and radiusY must be rotated, clockwise, to most accurately cover the area of contact between the user and the surface.
Touch.forceLecture seule
Returns the amount of pressure being applied to the surface by the user, as a float between 0.0 (no pressure) and 1.0 (maximum pressure).

Methods

This interface has no method and no parent, and doesn't inherits or implements any method.

Specifications

Specification Status Comment
Touch Events – Level 2
La définition de 'Touch' dans cette spécification.
Brouillon de l'éditeur Added radiusX, radiusY, rotationAngle, force properties, as well as the Touch() constructor.
Touch Events
La définition de 'Touch' dans cette spécification.
Recommendation Initial definition.

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 22.0 (Oui) 18.0 (18.0)[1]
52.0 (52.0)[2]
Pas de support Pas de support Pas de support
radiusX, radiusY, rotationAngle, force ? ? (Oui) ? ? ?
Touch() constructor ? Pas de support Pas de support ? ? ?
Feature Android Android Webview Chrome for Android Edge Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile
Basic support (Oui) (Oui) (Oui) (Oui) 6.0 (6.0) (Oui) 11 (Oui) (Oui)
radiusX, radiusY, rotationAngle, force ? ? ? ? 6.0 (6.0) (Oui) ? ? ?
Touch() constructor ? ? Pas de support ? Pas de support Pas de support ? ? ?

[1] Touch events were implemented in Gecko 18.0, but removed again in 24.0 (Firefox 24.0 / Thunderbird 24.0 / SeaMonkey 2.21) on the desktop version of Firefox due to web compatibility issues (bug 888304).

[2] As of Gecko 52.0, touch events support has been fixed and reenabled in Windows desktop platforms.

See also

Étiquettes et contributeurs liés au document

 Contributeurs à cette page : Felecarp
 Dernière mise à jour par : Felecarp,