From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../api/devicemotionevent/acceleration/index.html | 119 ++++++++++++++++++++ .../accelerationincludinggravity/index.html | 119 ++++++++++++++++++++ .../devicemotionevent/devicemotionevent/index.html | 38 +++++++ files/zh-cn/web/api/devicemotionevent/index.html | 80 ++++++++++++++ .../web/api/devicemotionevent/interval/index.html | 104 ++++++++++++++++++ .../api/devicemotionevent/rotationrate/index.html | 120 +++++++++++++++++++++ 6 files changed, 580 insertions(+) create mode 100644 files/zh-cn/web/api/devicemotionevent/acceleration/index.html create mode 100644 files/zh-cn/web/api/devicemotionevent/accelerationincludinggravity/index.html create mode 100644 files/zh-cn/web/api/devicemotionevent/devicemotionevent/index.html create mode 100644 files/zh-cn/web/api/devicemotionevent/index.html create mode 100644 files/zh-cn/web/api/devicemotionevent/interval/index.html create mode 100644 files/zh-cn/web/api/devicemotionevent/rotationrate/index.html (limited to 'files/zh-cn/web/api/devicemotionevent') diff --git a/files/zh-cn/web/api/devicemotionevent/acceleration/index.html b/files/zh-cn/web/api/devicemotionevent/acceleration/index.html new file mode 100644 index 0000000000..88646f7a72 --- /dev/null +++ b/files/zh-cn/web/api/devicemotionevent/acceleration/index.html @@ -0,0 +1,119 @@ +--- +title: DeviceMotionEvent.acceleration +slug: Web/API/DeviceMotionEvent/acceleration +tags: + - API + - Firefox OS + - 传感器 + - 运动传感器 + - 需要示例 +translation_of: Web/API/DeviceMotionEvent/acceleration +--- +

{{ ApiRef("Device Orientation Events") }}

+ +

acceleration属性会返回设备的加速度记录(单位:m / s2)。

+ +
注意: 如果硬件无法从acceleration数据中移除重力加速度,则该值在{{ domxref("DeviceMotionEvent") }}中可能并不存在,你应当使用{{ domxref("DeviceMotionEvent.accelerationIncludingGravity") }}代替
+ +

语法

+ +
var acceleration = instanceOfDeviceMotionEvent.acceleration;
+
+ +

+ +

acceleration是一个包括三轴(x、y、z)加速度信息的对象,每个轴都有自己的属性:

+ +
+
x
+
表示x轴(西到东)上的加速度
+
y
+
表示y轴(南到北)上的加速度
+
z
+
表示z轴(下到上)上的加速度
+
+ +

说明

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Device Orientation')}}{{Spec2('Device Orientation')}}Initial specification.
+ +

浏览器兼容性

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("6")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("6")}}{{CompatNo}}{{CompatNo}}4.2
+
+ +

推荐浏览

+ + diff --git a/files/zh-cn/web/api/devicemotionevent/accelerationincludinggravity/index.html b/files/zh-cn/web/api/devicemotionevent/accelerationincludinggravity/index.html new file mode 100644 index 0000000000..b35c619384 --- /dev/null +++ b/files/zh-cn/web/api/devicemotionevent/accelerationincludinggravity/index.html @@ -0,0 +1,119 @@ +--- +title: DeviceMotionEvent.accelerationIncludingGravity +slug: Web/API/DeviceMotionEvent/accelerationIncludingGravity +tags: + - API + - Firefox OS + - 传感器 + - 运动传感器 + - 需要示例 +translation_of: Web/API/DeviceMotionEvent/accelerationIncludingGravity +--- +

{{ ApiRef("Device Orientation Events") }}

+ +

accelerationIncludingGravity属性返回设备的加速度的记录,单位为米每秒平方(m / s2)与已移除重力加速度的{{domxref("DeviceMotionEvent.acceleration")}}不同,此值是由用户引起的设备的加速度和由重力加速度的总和。

+ +

此值通常不如{{domxref("DeviceMotionEvent.acceleration")}}实用,但是在部分不能自动从加速度数据中移除重力加速度的设备(例如没有陀螺仪的设备),是唯一可用值。

+ +

语法

+ +
var acceleration = instanceOfDeviceMotionEvent.accelerationIncludingGravity;
+
+ +

+ +

accelerationIncludingGravity是一个包括三轴(x、y、z)加速度信息的对象,每个轴都有自己的属性:

+ +
+
x
+
表示x轴(西到东)上的加速度
+
y
+
表示y轴(南到北)上的加速度
+
z
+
表示z轴(下到上)上的加速度
+
+ +

说明

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Device Orientation')}}{{Spec2('Device Orientation')}}Initial specification.
+ +

浏览器兼容性

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("6")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("6")}}{{CompatNo}}{{CompatNo}}4.2
+
+ +

推荐浏览

+ + diff --git a/files/zh-cn/web/api/devicemotionevent/devicemotionevent/index.html b/files/zh-cn/web/api/devicemotionevent/devicemotionevent/index.html new file mode 100644 index 0000000000..fcbe9a2864 --- /dev/null +++ b/files/zh-cn/web/api/devicemotionevent/devicemotionevent/index.html @@ -0,0 +1,38 @@ +--- +title: DeviceMotionEvent.DeviceMotionEvent() +slug: Web/API/DeviceMotionEvent/DeviceMotionEvent +translation_of: Web/API/DeviceMotionEvent/DeviceMotionEvent +--- +

{{APIRef("Device Orientation Events")}}{{Non-standard_header}}

+ +

The DeviceMotionEvent constructor 会创建一个新的 {{DOMxRef("DeviceMotionEvent")}}.

+ +

语法

+ +
var deviceMotionEvent = new DeviceMotionEvent(type[, options])
+ +

参数

+ +
+
type
+
必须是 "devicemotion".
+
options{{Optional_Inline}}
+
可选项如下: +
    +
  • acceleration: 一个对象,包含设备在X,Y和Z三个轴线上的加速度。加速度的单位为m/s2.
  • +
  • accelerationIncludingGravity: 一个对象,包含设备在X,Y和Z三个轴线上,重力作用下的加速度。加速度的单位为m/s2.
  • +
  • rotationRate: 一个对象,包含设备的定向在三个定向轴alpha, beta 和 gamma上的偏移比率。偏移比率的单位是每秒偏移的角度。
  • +
  • interval: 时间间隔,单位毫秒,表示设备获取数据的间隔时间。
  • +
+
+
+ +

说明

+ +

无特别说明。

+ +

浏览器兼容

+ + + +

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

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")}}

+ +

参见

+ + diff --git a/files/zh-cn/web/api/devicemotionevent/interval/index.html b/files/zh-cn/web/api/devicemotionevent/interval/index.html new file mode 100644 index 0000000000..d96a237274 --- /dev/null +++ b/files/zh-cn/web/api/devicemotionevent/interval/index.html @@ -0,0 +1,104 @@ +--- +title: DeviceMotionEvent.interval +slug: Web/API/DeviceMotionEvent/interval +tags: + - API + - Firefox OS + - 传感器 + - 运动传感器 + - 需要示例 +translation_of: Web/API/DeviceMotionEvent/interval +--- +

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

+ +

返回从底层硬件获取数据的时间间隔(单位:毫秒)。 您可以使用它来确定运动事件的粒度。

+ +

语法

+ +
var interval = instanceOfDeviceMotionEvent.interval;
+
+ +

说明

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Device Orientation')}}{{Spec2('Device Orientation')}}Initial specification.
+ +

浏览器兼容性

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("6")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("6")}}{{CompatNo}}{{CompatNo}}4.2
+
+ +

推荐浏览

+ + diff --git a/files/zh-cn/web/api/devicemotionevent/rotationrate/index.html b/files/zh-cn/web/api/devicemotionevent/rotationrate/index.html new file mode 100644 index 0000000000..513d403ec0 --- /dev/null +++ b/files/zh-cn/web/api/devicemotionevent/rotationrate/index.html @@ -0,0 +1,120 @@ +--- +title: DeviceMotionEvent.rotationRate +slug: Web/API/DeviceMotionEvent/rotationRate +tags: + - API + - DOM + - Firefox OS + - 传感器 + - 运动传感器 + - 需要示例 +translation_of: Web/API/DeviceMotionEvent/rotationRate +--- +

{{ ApiRef("Device Orientation Events") }}

+ +

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

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

语法

+ +
var rates = instanceOfDeviceMotionEvent.rotationRate;
+
+ +

+ +

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

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

说明

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
{{SpecName('Device Orientation')}}{{Spec2('Device Orientation')}}Initial specification.
+ +

浏览器兼容性

+ +

{{CompatibilityTable}}

+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureChromeEdgeFirefox (Gecko)Internet ExplorerOperaSafari (WebKit)
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoDesktop("6")}}{{CompatUnknown}}{{CompatUnknown}}{{CompatUnknown}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
FeatureAndroidEdgeFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Basic support{{CompatVersionUnknown}}{{CompatVersionUnknown}}{{CompatGeckoMobile("6")}}{{CompatNo}}{{CompatNo}}4.2
+
+ +

推荐阅读

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