Accelerometer plugin for NativeScript
MIT License
Accelerometer plugin for NativeScript
tns plugin add nativescript-accelerometer
var accelerometer = require("nativescript-accelerometer");
accelerometer.startAccelerometerUpdates(function(data) {
console.log("x: " + data.x + "y: " + data.y + "z: " + data.z);
}, { sensorDelay: "ui" });
You can control how often the callback will be called by setting the sensorDelay
option. The values are:
"normal"
- Suitable for screen orientation changes. Around 0.2 seconds."ui"
- Suitable for the user interface. Around 0.06 seconds."game"
- Suitable for games. Around 0.02 seconds."fastest"
- Sensor data as fast as possible.