DeviceMotionEvent.acceleration

  • Revision slug: Web/API/DeviceMotionEvent.acceleration
  • Revision title: DeviceMotionEvent.acceleration
  • Revision id: 475363
  • Created:
  • Creator: kscarfone
  • Is current revision? Yes
  • Comment Updated tags

Revision Content

{{ DomRef() }}

Summary

The acceleration property returns the amount of acceleration recorded by the device, in meters per second squared (m/s2).

Note: If the hardware doesn't know how to remove gravity from the acceleration data, this value may not be present in the {{ domxref("DeviceMotionEvent") }}. In this situation, you'll need to use {{ domxref("DeviceMotionEvent.accelerationIncludingGravity") }} instead.

Syntax

var acceleration = instanceOfDeviceMotionEvent.acceleration;

Value

The acceleration property is an object providing information about acceleration on three axis. Each axis is represented with its own property:

x
Represents the acceleration upon the x axis which is the west to east axis
y
Represents the acceleration upon the y axis which is the south to north axis
z
Represents the acceleration upon the z axis which is the down to up axis

Specifications

Specification Status Comment
{{SpecName('Device Orientation')}} {{Spec2('Device Orientation')}} Initial specification.

Browser compatibility

{{ page("/en-US/docs/Web/API/DeviceMotionEvent","Browser_compatibility") }}

See also

Revision Source

<p>{{ DomRef() }}</p>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code>acceleration</code> property returns the amount of acceleration recorded by the device, in <a href="https://en.wikipedia.org/wiki/Meter_per_second_squared" title="https://en.wikipedia.org/wiki/Meter_per_second_squared">meters per second squared (m/s<sup>2</sup>)</a>.</p>
<div class="note">
  <strong>Note:</strong> If the hardware doesn't know how to remove gravity from the acceleration data, this value may not be present in the {{ domxref("DeviceMotionEvent") }}. In this situation, you'll need to use {{ domxref("DeviceMotionEvent.accelerationIncludingGravity") }} instead.</div>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="eval">
var acceleration = <em>instanceOfDeviceMotionEvent</em>.acceleration;
</pre>
<h2 id="Example" name="Example">Value</h2>
<p>The <code>acceleration</code> property is an object providing information about acceleration on three axis. Each axis is represented with its own property:</p>
<dl>
  <dt>
    <code>x</code></dt>
  <dd>
    Represents the acceleration upon the x axis which is the west to east axis</dd>
  <dt>
    <code>y</code></dt>
  <dd>
    Represents the acceleration upon the y axis which is the south to north axis</dd>
  <dt>
    <code>z</code></dt>
  <dd>
    Represents the acceleration upon the z axis which is the down to up axis</dd>
</dl>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{SpecName('Device Orientation')}}</td>
      <td>{{Spec2('Device Orientation')}}</td>
      <td>Initial specification.</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ page("/en-US/docs/Web/API/DeviceMotionEvent","Browser_compatibility") }}</p>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{ domxref("DeviceMotionEvent.accelerationIncludingGravity") }}</li>
  <li>{{ event("devicemotion") }}</li>
  <li>{{ domxref("window.ondevicemotion") }}</li>
  <li>{{ event("deviceorientation") }}</li>
  <li>{{ domxref("DeviceOrientationEvent") }}</li>
  <li><a href="/en-US/docs/WebAPI/Detecting_device_orientation" title="/en-US/docs/WebAPI/Detecting_device_orientation">Detecting device orientation</a></li>
  <li><a href="https://developer.mozilla.org/en/DOM/Orientation_and_motion_data_explained" title="Orientation and motion data explained">Orientation and motion data explained</a></li>
</ul>
Revert to this revision