- android
- symbian
getCurrentAcceleration
Syntax
navigator.accelerometer.getCurrentAcceleration(win, fail);
Arguments
winFunction
failFunction
Example
function getAccel() {
var win = function(a){
document.getElementById('x').innerHTML = a.x;
document.getElementById('y').innerHTML = a.y;
document.getElementById('z').innerHTML = a.z;
};
var fail = function(){};
navigator.accelerometer.getCurrentAcceleration(win, fail);
}
- iphone
- android
- symbian
watchAcceleration
Syntax
navigator.accelerometer.watchAcceleration(win, fail, opts);
Arguments
winFunction
failFunction
opts (Optional)Object
Example
function watchAccel() {
var win = function(a){
document.getElementById('x').innerHTML = a.x;
document.getElementById('y').innerHTML = a.y;
document.getElementById('z').innerHTML = a.z;
};
var fail = function(){};
var opt = {};
opt.frequency = 100;
watchId = navigator.accelerometer.watchAcceleration(win, fail, opt);
}
- Android
- symbian
clearWatch
Syntax
navigator.acelerometer.clearWatch(watchId);
Arguments
watchIdnumber
Example
navigator.accelerometer.clearWatch(watchId)