LinearAccelerationSensor: hàm khởi tạo LinearAccelerationSensor()
Khả dụng hạn chế
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Hàm khởi tạo LinearAccelerationSensor() tạo một đối tượng LinearAccelerationSensor mới cung cấp trong mỗi lần đọc gia tốc được áp dụng lên thiết bị theo cả ba trục, nhưng không bao gồm đóng góp của trọng lực.
Cú pháp
new LinearAccelerationSensor()
new LinearAccelerationSensor(options)
Tham số
optionsOptional-
Các tùy chọn như sau:
frequencyOptional-
Số lần mong muốn lấy mẫu mỗi giây, tức là số lần sự kiện
readingsẽ được gọi mỗi giây. Có thể sử dụng số nguyên hoặc số thập phân, cái sau dành cho tần số nhỏ hơn một giây. Tần số đọc thực tế phụ thuộc vào phần cứng của thiết bị và do đó có thể nhỏ hơn yêu cầu. referenceFrameOptional-
Một trong
'device'hoặc'screen'. Mặc định là'device'.
Ngoại lệ
SecurityErrorDOMException-
Việc sử dụng tính năng này bị chặn bởi Permissions Policy.
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Accelerometer> # dom-linearaccelerationsensor-linearaccelerationsensor> |
Tương thích trình duyệt
Xem thêm
- Sự kiện
reading