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”
。
异常
SecurityError
DOMException
-
此特性的使用被权限策略阻止。
规范
Specification |
---|
Accelerometer # dom-linearaccelerationsensor-linearaccelerationsensor |
浏览器兼容性
BCD tables only load in the browser
参见
reading
事件