Move the image to the side while tilting the iPad

I tried to create the following effect with no success and would greatly appreciate any help provided

The effect moves the image from left to right according to the tilt of the iPad. The iPad is stored in landscape view, and the image has to move from left to right (actually up and down). The width of the image doubles at the iPad stage (2048 pixels) and must duplicate itsefe when reaching the end of the window. Can anyone help me get started on this? thanks in advance

+3


source to share


1 answer


This should be enough to get you started: http://jsfiddle.net/kennis/S9swv/

Basically, you care about the 'deviceorientation' event. This event object gives you some useful pieces of data - e.alpha, e.beta and e.gamma.



Each property is a measure of rotation along a given axis, ranging from negative 180 to positive 180.

Fun fact: this also works on MacBook Pros (at least Chrome).

+2


source







All Articles