We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

DeviceMotionEvent.acceleration

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

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

语法

var acceleration = instanceOfDeviceMotionEvent.acceleration;

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

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

说明

Specification Status Comment
Device Orientation Events Working 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!

  
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

推荐浏览

文档标签和贡献者

此页面的贡献者: shuangya
最后编辑者: shuangya,