Window: devicemotion event
Baseline 2023Newly available
Since September 2023, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.
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 |
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 |
---|
Device Orientation and Motion # devicemotion |
Device Orientation and Motion # ref-for-dom-window-ondevicemotion |
Compatibilité des navigateurs
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
devicemotion event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.