Window: devicemotion event

L'évènement devicemotion est déclenché à intervalles réguliers et indique la quantité de force physique d'accélération que le périphérique reçoit à ce moment. Il fournit également des informations sur le taux de rotation, si disponible.

Bouillonne Non
Annulable Non
Interface DeviceMotionEvent
Propriété gestionnaire d'évènement Window.ondevicemotion (en-US)

Exemples

js
function handleMotionEvent(event) {
  var x = event.accelerationIncludingGravity.x;
  var y = event.accelerationIncludingGravity.y;
  var z = event.accelerationIncludingGravity.z;

  // Faire quelque chose de génial.
}

window.addEventListener("devicemotion", handleMotionEvent, true);

Spécifications

Specification
DeviceOrientation Event Specification
# devicemotion
DeviceOrientation Event Specification
# ref-for-dom-window-ondevicemotion

Compatibilité des navigateurs

BCD tables only load in the browser

Voir aussi