1.0.1 • Published 6 years ago
universal-accelerometer
Licence
—
Version
1.0.1
Deps
1
Size
7 kB
Vulns
0
Weekly
0
universal-accelerometer 
Accelerometer monitor and cancel.
Support
Install
$ npm install universal-accelerometer --save
Methods
onChange(callback): void
Monitoring acceleration data, the callback interval is 500ms, the interface calls will automatically start listening, can use offChange() to stop listening.
Parameters
| Property | Type | Description | Support |
|---|---|---|---|
| callback | Function |
The callback function |
offChange(): void
Stop listening for acceleration data.
Example
import Accelerometer from 'universal-accelerometer';
Accelerometer.onChange(res => {
console.log(res.x);
console.log(res.y);
console.log(res.z);
});
Accelerometer.offChange();