LinearAccelerationSensor:LinearAccelerationSensor() 构造函数
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
LinearAccelerationSensor() 构造函数创建一个新的 LinearAccelerationSensor 对象,它在每次读取时提供沿所有三个轴加到设备上的加速度(不包含重力加速度)。
语法
js
new LinearAccelerationSensor()
new LinearAccelerationSensor(options)
参数
options可选-
选项如下:
frequency可选-
每秒采样所需的次数,即每秒调用
reading事件的次数。可使用整数或者小数,小数用于小于一秒的频率。实际读取频率取决于设备硬件,因此可能小于所请求的频率。 referenceFrame可选-
“device”或“screen”,默认值是“device”。
异常
SecurityErrorDOMException-
此特性的使用被权限策略阻止。
规范
| Specification |
|---|
| Accelerometer> # dom-linearaccelerationsensor-linearaccelerationsensor> |
浏览器兼容性
参见
reading事件