diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:40:17 -0500 |
commit | 33058f2b292b3a581333bdfb21b8f671898c5060 (patch) | |
tree | 51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/devicemotionevent/index.html | |
parent | 8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff) | |
download | translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2 translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip |
initial commit
Diffstat (limited to 'files/zh-cn/web/api/devicemotionevent/index.html')
-rw-r--r-- | files/zh-cn/web/api/devicemotionevent/index.html | 80 |
1 files changed, 80 insertions, 0 deletions
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 +--- +<p>{{apiref("Device Orientation Events")}}{{SeeCompatTable}}</p> + +<p><code>DeviceMotionEvent</code> 为web开发者提供了关于设备的位置和方向的改变速度的信息。</p> + +<div class="warning"> +<p><strong>警告:</strong>目前,Firefox 和 Chrome 处理坐标的方式不同。 使用时要多加注意。</p> +</div> + +<h2 id="构造函数">构造函数</h2> + +<dl> + <dt>{{DOMxRef("DeviceMotionEvent.DeviceMotionEvent()")}} {{Non-standard_Inline}}</dt> + <dd>创建一个新的 <code>DeviceMotionEvent</code>。</dd> +</dl> + +<h2 id="属性">属性</h2> + +<dl> + <dt>{{domxref("DeviceMotionEvent.acceleration")}} {{readonlyinline}}</dt> + <dd>提供了设备在X,Y,Z轴方向上加速度的对象。加速度的单位为 <a href="https://en.wikipedia.org/wiki/Meter_per_second_squared" title="https://en.wikipedia.org/wiki/Meter_per_second_squared">m/s<sup>2</sup></a>。</dd> + <dt>{{domxref("DeviceMotionEvent.accelerationIncludingGravity")}} {{readonlyinline}}</dt> + <dd>提供了设备在X,Y,Z轴方向上带重力的加速度的对象。加速度的单位为 <a href="https://en.wikipedia.org/wiki/Meter_per_second_squared" title="https://en.wikipedia.org/wiki/Meter_per_second_squared">m/s<sup>2</sup></a></dd> + <dt>{{domxref("DeviceMotionEvent.rotationRate")}} {{readonlyinline}}</dt> + <dd>提供了设备在 alpha,beta, gamma轴方向上旋转的速率的对象。旋转速率的单位为度每秒。</dd> + <dt>{{domxref("DeviceMotionEvent.interval")}} {{readonlyinline}}</dt> + <dd>表示从设备获取数据的间隔时间,单位是毫秒。</dd> +</dl> + +<h2 id="示例">示例</h2> + +<pre class="brush: js">window.addEventListener('devicemotion', function(event) { + console.log(event.acceleration.x + ' m/s2'); +});</pre> + +<h2 id="规范">规范</h2> + +<table> + <thead> + <tr> + <th scope="col"><strong>规范</strong></th> + <th scope="col"><strong>状态</strong></th> + <th scope="col"><strong>注释</strong></th> + </tr> + </thead> + <tbody> + <tr> + <td>{{SpecName("Device Orientation", "#devicemotionevent", "DeviceMotionEvent")}}</td> + <td>{{Spec2("Device Orientation")}}</td> + <td>Initial definition.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<p>{{Compat("api.DeviceMotionEvent")}}</p> + +<h2 id="参见">参见</h2> + +<ul> + <li>{{Event("deviceorientation")}}</li> + <li>{{DOMxRef("DeviceOrientationEvent")}}</li> + <li>{{Event("devicemotion")}}</li> + <li><a href="https://wiki.developer.mozilla.org/en-US/docs/WebAPI/Detecting_device_orientation" title="/en-US/docs/WebAPI/Detecting_device_orientation">Detecting device orientation</a></li> + <li><a href="https://developer.mozilla.org/en/DOM/Orientation_and_motion_data_explained" title="Orientation and motion data explained">Orientation and motion data explained</a></li> +</ul> |