This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
The DeviceOrientationEvent
provides web developers with information from the physical orientation of the device running the web page.
Warning: Currently, Firefox and Chrome do not handle the coordinates the same way. Take care about this while using them.
Constructor
DeviceOrientationEvent.DeviceOrientationEvent()
- Creates a new
DeviceOrientationEvent
.
Properties
DeviceOrientationEvent.absolute
Read only- A boolean that indicates whether or not the device is providing orientation data absolutely.
DeviceOrientationEvent.alpha
Read only- A number representing the motion of the device around the z axis, express in degrees with values ranging from 0 to 360.
DeviceOrientationEvent.beta
Read only- A number representing the motion of the device around the x axis, express in degrees with values ranging from -180 to 180. This represents a front to back motion of the device.
DeviceOrientationEvent.gamma
Read only- A number representing the motion of the device around the y axis, express in degrees with values ranging from -90 to 90. This represents a left to right motion of the device.
- DeviceOrientationEvent.webkitCompassHeading Read only
- A number represents the difference between the motion of the device around the z axis of the world system and the direction of the north, express in degrees with values ranging from 0 to 360.
- DeviceOrientationEvent.webkitCompassAccuracy Read only
- The accuracy of the compass means that the deviation is positive or negative. It's usually 10.
Example
window.addEventListener('deviceorientation', function(event) { console.log(event.alpha + ' : ' + event.beta + ' : ' + event.gamma); });
Specifications
Specification | Status | Comment |
---|---|---|
DeviceOrientation Event Specification | Editor's Draft | Initial specification. |
Browser compatibility
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.
Update compatibility data on GitHub
Desktop | Mobile | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Basic support | Chrome
Full support
7
| Edge Full support Yes | Firefox
Full support
6
| IE ? | Opera ? | Safari ? | WebView Android
Full support
Yes
| Chrome Android
Full support
Yes
| Edge Mobile Full support Yes | Firefox Android
Full support
6
| Opera Android No support No | Safari iOS Full support 4.2 | Samsung Internet Android ? |
DeviceOrientationEvent() constructor | Chrome Full support 59 | Edge ? | Firefox ? | IE ? | Opera ? | Safari ? | WebView Android Full support 59 | Chrome Android Full support 59 | Edge Mobile ? | Firefox Android ? | Opera Android ? | Safari iOS ? | Samsung Internet Android ? |
absolute | Chrome Full support 7 | Edge Full support Yes | Firefox Full support 6 | IE ? | Opera ? | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 6 | Opera Android No support No | Safari iOS Full support 4.2 | Samsung Internet Android ? |
alpha | Chrome Full support 7 | Edge Full support Yes | Firefox Full support 6 | IE ? | Opera ? | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 6 | Opera Android No support No | Safari iOS Full support 4.2 | Samsung Internet Android ? |
beta | Chrome Full support 7 | Edge Full support Yes | Firefox Full support 6 | IE ? | Opera ? | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 6 | Opera Android No support No | Safari iOS Full support 4.2 | Samsung Internet Android ? |
gamma | Chrome Full support 7 | Edge Full support Yes | Firefox Full support 6 | IE ? | Opera ? | Safari ? | WebView Android Full support Yes | Chrome Android Full support Yes | Edge Mobile Full support Yes | Firefox Android Full support 6 | Opera Android No support No | Safari iOS Full support 4.2 | Samsung Internet Android ? |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
- Experimental. Expect behavior to change in the future.
- Experimental. Expect behavior to change in the future.
- Non-standard. Expect poor cross-browser support.
- Non-standard. Expect poor cross-browser support.
- See implementation notes.
- See implementation notes.
See also
Document Tags and Contributors
Tags:
Contributors to this page:
fscholz,
lucian95,
Mrluobo,
jpmedley,
erikadoyle,
zeke,
kollishivagangadhar,
teoli,
Maroosko,
kscarfone,
justinpotts,
Jeremie
Last updated by:
fscholz,