lynx   »   [go: up one dir, main page]

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

DeviceMotionEvent.DeviceMotionEvent()

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

非标准: 该特性尚未标准化。我们不建议在生产环境中使用非标准特性,因为它们在浏览器中的支持有限,且可能发生变化或被移除。不过,在没有标准选项的特定情况下,它们可以作为合适的替代方案。

The DeviceMotionEvent constructor 会创建一个新的 DeviceMotionEvent.

语法

js
new DeviceMotionEvent(type)
new DeviceMotionEvent(type, options)

参数

type

必须是 "devicemotion".

options可选

可选项如下:

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

说明

无特别说明。

浏览器兼容性

Лучший частный хостинг