aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/window/devicemotion_event/index.md
blob: be4a8f34438ffb44af98c1b797cb995a6256ff04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
title: 'Window: devicemotion event'
slug: Web/API/Window/devicemotion_event
translation_of: Web/API/Window/devicemotion_event
browser-compat: api.Window.devicemotion_event
---
{{APIRef}}

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.

<table class="properties">
  <tbody>
    <tr>
      <th scope="row">Bouillonne</th>
      <td>Non</td>
    </tr>
    <tr>
      <th scope="row">Annulable</th>
      <td>Non</td>
    </tr>
    <tr>
      <th scope="row">Interface</th>
      <td><a href="/fr/docs/Web/API/DeviceMotionEvent"><code>DeviceMotionEvent</code></a></td>
    </tr>
    <tr>
      <th scope="row">Propriété gestionnaire d'évènement</th>
      <td><a href="/fr/docs/Web/API/Window/ondevicemotion"><code>Window.ondevicemotion</code></a></td>
    </tr>
  </tbody>
</table>

## 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

{{Specifications}}

## Compatibilité des navigateurs

{{Compat}}

## Voir aussi

- [`deviceorientation`](/fr/docs/Web/API/Window/deviceorientation_event)
- [`DeviceOrientation Event` (en anglais)](https://www.w3.org/TR/orientation-event/#devicemotion)