IOS 4.2 (with new Safari Mobile) has the possibility to read sensor data like accelerometer and gyroscope directly from Javascript.
New Javascript objects and event handler
From javascript point of view, we have:
- new handler window.ondevicemotion
- new event object:
- event.accelerationGravity, with x, y, z attributes
- event.accelerationIncludingGravity, with x, y, z attributes
- event.rotationRate, with alpha, beta, gamma attributes
Code Snip
window.ondevicemotion = function(event) {
var accelerationX = event.accelerationIncludingGravity.x;
var accelerationY = event.accelerationIncludingGravity.y;
var accelerationZ = event.accelerationIncludingGravity.z;
}
Demo
Online Demo (require Safari Mobile)
this post is very usefull thx!
Excellent. I’m using this in my upcoming website: http://www.progettystudio.com
That is very fascinating, You’re a very professional blogger. I’ve joined your feed and look forward to looking for extra of your excellent post. Also, I’ve shared your website in my social networks