coderef

Orientation SensorLimited availability

The AbsoluteOrientationSensor and RelativeOrientationSensor APIs describe the physical orientation of a device in three-dimensional space, either in relation to the Earth's coordinate system or in relation to the device's own orientation, respectively.

Not yet supported in all major browsers — check the table and provide a fallback.

Browser support

DesktopChrome
1–66Not supported
67+Supportedsince May 29, 2018
Current: 155
Edge
12–18Not supported
79+Supportedsince Jan 15, 2020
Current: 154
Firefox
✕Not supportedup to 157
Current: 157
Safari
✕Not supportedup to 27
Current: 27
MobileChrome Android
18–66Not supported
67+Supportedsince May 31, 2018
Current: 155
Firefox Android
✕Not supportedup to 157
Current: 157
Safari iOS
✕Not supportedup to 27
Current: 27

How to use

Not supported in Firefox, Safari, Firefox Android, Safari iOS. Use feature detection below and provide a fallback (or a polyfill) for those browsers.

Example

Full syntax and examples are on MDN: AbsoluteOrientationSensor.

Feature detection

JS · check before using
if ("OrientationSensor" in globalThis) {
  // OrientationSensor is available
} else {
  // load a polyfill or use a fallback
}

Sub-features

Support for each part of the feature (19). The overall table above shows when the whole feature works.

Sub-featureChromeEdgeFirefoxSafariChrome AndroidFirefox AndroidSafari iOS
AbsoluteOrientationSensor6779✕✕67✕✕
AbsoluteOrientationSensor.AbsoluteOrientationSensor6779✕✕67✕✕
OrientationSensor6779✕✕67✕✕
OrientationSensor.populateMatrix6779✕✕67✕✕
OrientationSensor.quaternion6779✕✕67✕✕
RelativeOrientationSensor6779✕✕67✕✕
RelativeOrientationSensor.RelativeOrientationSensor6779✕✕67✕✕
Sensor6779✕✕67✕✕
Sensor.activate_event6779✕✕67✕✕
Sensor.activated6779✕✕67✕✕
Sensor.error_event6779✕✕67✕✕
Sensor.hasReading6779✕✕67✕✕
Sensor.reading_event6779✕✕67✕✕
Sensor.start6779✕✕67✕✕
Sensor.stop6779✕✕67✕✕
Sensor.timestamp6779✕✕67✕✕
SensorErrorEvent6779✕✕67✕✕
SensorErrorEvent.SensorErrorEvent6779✕✕67✕✕
SensorErrorEvent.error6779✕✕67✕✕