Created
April 22, 2015 19:00
-
-
Save eklimcz-zz/55bda51a8a72b841dd36 to your computer and use it in GitHub Desktop.
Get Accerlerometer values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//check for mobile and accerlerometer support | |
if(this.isMobile && window.DeviceOrientationEvent) { | |
//wireup the event | |
window.addEventListener('deviceorientation', function(eventData){ | |
//grab the accelerometer values | |
this.target.x = eventData.gamma * 2; //exaggerate the effect | |
this.target.y = eventData.beta * 3; | |
}, false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment