DeviceMotionEvent.accelerationIncludingGravity

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

Revision Content

{{ DomRef() }}

Summary

The accelerationIncludingGravity property returns the amount of acceleration recorded by the device, in meters per second squared (m/s2). Unlike {{ domxref("DeviceMotionEvent.acceleration") }} which does not compensate for the influence of gravity, its value is the sum of the acceleration of the device as induced by the user and the acceleration caused by gravity.

This value is not typically as useful as {{ domxref("DeviceMotionEvent.acceleration") }}, but may be the only value available on devices that aren't able of removing gravity from the acceleration data, such as on devices that don't have a gyroscope.

Syntax

var acceleration = instanceOfDeviceMotionEvent.accelerationIncludingGravity;

Value

The accelerationIncludingGravity 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>accelerationIncludingGravity</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>. Unlike {{ domxref("DeviceMotionEvent.acceleration") }} which does not compensate for the influence of gravity, its value is the sum of the acceleration of the device as induced by the user and the acceleration caused by gravity.</p>
<p>This value is not typically as useful as {{ domxref("DeviceMotionEvent.acceleration") }}, but may be the only value available on devices that aren't able of removing gravity from the acceleration data, such as on devices that don't have a gyroscope.</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="eval">
var acceleration = <em>instanceOfDeviceMotionEvent</em>.accelerationIncludingGravity;
</pre>
<h2 id="Example" name="Example">Value</h2>
<p>The <code>accelerationIncludingGravity</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.acceleration") }}</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