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.
DeviceOrientationEvent.DeviceOrientationEvent()
DeviceOrientationEvent
.DeviceOrientationEvent.absolute
Read only
DeviceOrientationEvent.alpha
Read only
DeviceOrientationEvent.beta
Read only
DeviceOrientationEvent.gamma
Read only
window.addEventListener('deviceorientation', function(event) { console.log(event.alpha + ' : ' + event.beta + ' : ' + event.gamma); });
Specification | Status | Comment |
---|---|---|
Device Orientation Events | Working Draft | Initial specification. |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 7
|
Yes | 6
|
? | ? | ? |
DeviceOrientationEvent() constructor
|
59 | ? | ? | ? | ? | ? |
absolute
|
7 | Yes | 6 | ? | ? | ? |
alpha
|
7 | Yes | 6 | ? | ? | ? |
beta
|
7 | Yes | 6 | ? | ? | ? |
gamma
|
7 | Yes | 6 | ? | ? | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes
|
Yes
|
Yes | 6
|
No | 4.2 | ? |
DeviceOrientationEvent() constructor
|
59 | 59 | ? | ? | ? | ? | ? |
absolute
|
Yes | Yes | Yes | 6 | No | 4.2 | ? |
alpha
|
Yes | Yes | Yes | 6 | No | 4.2 | ? |
beta
|
Yes | Yes | Yes | 6 | No | 4.2 | ? |
gamma
|
Yes | Yes | Yes | 6 | No | 4.2 | ? |
deviceorientation
DeviceMotionEvent
devicemotion
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/DeviceOrientationEvent