Device motion and orientation data

In continue to my previous post, I decided to take the first step in building my next project (more about it soon).

I  followed the Web API instructions about how to detect device’s movement (using the device accelerometer sensor) and orientation (using the device orientation sensor), and experimented with getting and presenting the this data.

You can see the end result here.

I wrote the following code for the task (This code gets the device movement and orientation data, and appends it to the DOM’s body) –

And this is the result (the changes in the blue numbers occur because I rotated my phone, while the most of the changes in the red numbers cause because the Web API library is still in beta, and doesn’t deal well enough with the device accelerometer) –

Apparently, my Macbook Pro also has an accelerometer, to protect its hard-drive while moving the laptop –

Try it yourself.

Here’s the entire code on GitHub.