From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/zh-cn/web/api/devicemotionevent/index.html | 80 ++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 files/zh-cn/web/api/devicemotionevent/index.html (limited to 'files/zh-cn/web/api/devicemotionevent/index.html') diff --git a/files/zh-cn/web/api/devicemotionevent/index.html b/files/zh-cn/web/api/devicemotionevent/index.html new file mode 100644 index 0000000000..c0a4d3868c --- /dev/null +++ b/files/zh-cn/web/api/devicemotionevent/index.html @@ -0,0 +1,80 @@ +--- +title: DeviceMotionEvent +slug: Web/API/DeviceMotionEvent +tags: + - API + - DeviceMotionEvent + - 传感器 + - 参考 + - 实验性 + - 接口 + - 移动设备 + - 运动传感器 +translation_of: Web/API/DeviceMotionEvent +--- +

{{apiref("Device Orientation Events")}}{{SeeCompatTable}}

+ +

DeviceMotionEvent 为web开发者提供了关于设备的位置和方向的改变速度的信息。

+ +
+

警告:目前,Firefox 和 Chrome 处理坐标的方式不同。 使用时要多加注意。

+
+ +

构造函数

+ +
+
{{DOMxRef("DeviceMotionEvent.DeviceMotionEvent()")}} {{Non-standard_Inline}}
+
创建一个新的 DeviceMotionEvent
+
+ +

属性

+ +
+
{{domxref("DeviceMotionEvent.acceleration")}} {{readonlyinline}}
+
提供了设备在X,Y,Z轴方向上加速度的对象。加速度的单位为 m/s2
+
{{domxref("DeviceMotionEvent.accelerationIncludingGravity")}} {{readonlyinline}}
+
提供了设备在X,Y,Z轴方向上带重力的加速度的对象。加速度的单位为 m/s2
+
{{domxref("DeviceMotionEvent.rotationRate")}} {{readonlyinline}}
+
提供了设备在 alpha,beta, gamma轴方向上旋转的速率的对象。旋转速率的单位为度每秒。
+
{{domxref("DeviceMotionEvent.interval")}} {{readonlyinline}}
+
表示从设备获取数据的间隔时间,单位是毫秒。
+
+ +

示例

+ +
window.addEventListener('devicemotion', function(event) {
+  console.log(event.acceleration.x + ' m/s2');
+});
+ +

规范

+ + + + + + + + + + + + + + + + +
规范状态注释
{{SpecName("Device Orientation", "#devicemotionevent", "DeviceMotionEvent")}}{{Spec2("Device Orientation")}}Initial definition.
+ +

浏览器兼容性

+ +

{{Compat("api.DeviceMotionEvent")}}

+ +

参见

+ + -- cgit v1.2.3-54-g00ecf