DeviceMotionEvent.rotationRate

返回设备围绕其每个轴(x、y、z)旋转的速率(单位:度/秒)。

注意: 如果设备无法提供此信息,则为null

语法

var rates = instanceOfDeviceMotionEvent.rotationRate;

rotationRates属性是一个只读对象,用于描述设备围绕其每个轴的旋转速率:

alpha
设备绕其Z轴旋转的速率(即绕垂直于屏幕的线旋转)
beta
设备绕其X轴旋转的速率(即从前到后旋转)
gamma
设备绕其Y轴旋转的速率(即从一侧到另一侧)

说明

Specification Status Comment
DeviceOrientation Event Specification Editor's Draft Initial specification.

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help! (en-US)

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (Yes) (Yes) 6 (6) ? ? ?
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) 6.0 (6) 未实现 未实现 4.2

推荐阅读