这是
实验性技术
检查
浏览器兼容性表格
要小心谨慎在生产中使用这之前。
DeviceMotionEvent
provides web developers with information about the speed of changes for the device's position and orientation.
警告: Currently, Firefox and Chrome do not handle the coordinates the same way. Take care about this while using them.
DeviceMotionEvent.DeviceMotionEvent()
DeviceMotionEvent
.
DeviceMotionEvent.acceleration
只读
DeviceMotionEvent.accelerationIncludingGravity
只读
DeviceMotionEvent.rotationRate
只读
An object giving the rate of change of the device's orientation on the three orientation axis alpha, beta and gamma. Rotation rate is expressed in degrees per seconds.
DeviceMotionEvent.interval
只读
A number representing the interval of time, in milliseconds, at which data is obtained from the device.
window.addEventListener('devicemotion', function(event) {
console.log(event.acceleration.x + ' m/s2');
});
| 规范 | 状态 | 注释 |
|---|---|---|
|
DeviceOrientation Event Specification
The definition of 'DeviceMotionEvent' in that specification. |
编者草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
DeviceMotionEvent
|
Chrome 11 | Edge ≤18 | Firefox 6 | IE No | Opera 15 | Safari 5 | WebView Android ≤37 | Chrome Android 18 | Firefox Android 6 | Opera Android 14 | Safari iOS 4.2 | Samsung Internet Android 1.0 |
DeviceMotionEvent()
构造函数
非标
|
Chrome 59 | Edge ≤79 | Firefox ? | IE No | Opera ? | Safari ? | WebView Android 59 | Chrome Android 59 | Firefox Android ? | Opera Android ? | Safari iOS ? | Samsung Internet Android 7.0 |
acceleration
|
Chrome Yes | Edge 12 | Firefox 6 | IE No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android Yes | Firefox Android 6 | Opera Android ? | Safari iOS 4.2 | Samsung Internet Android Yes |
accelerationIncludingGravity
|
Chrome Yes | Edge 12 | Firefox 6 | IE No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android Yes | Firefox Android 6 | Opera Android Yes | Safari iOS 4.2 | Samsung Internet Android Yes |
interval
|
Chrome Yes | Edge 12 | Firefox 6 | IE No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android Yes | Firefox Android 6 | Opera Android Yes | Safari iOS 4.2 | Samsung Internet Android Yes |
rotationRate
|
Chrome Yes | Edge 12 | Firefox 6 | IE No | Opera Yes | Safari ? | WebView Android Yes | Chrome Android Yes | Firefox Android 6 | Opera Android Yes | Safari iOS 4.2 | Samsung Internet Android Yes |
完整支持
不支持
兼容性未知
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
deviceorientation
DeviceOrientationEvent
devicemotion
DeviceMotionEvent