Skip to content

Instantly share code, notes, and snippets.

@eklimcz-zz
Created April 22, 2015 19:00
Show Gist options
  • Save eklimcz-zz/55bda51a8a72b841dd36 to your computer and use it in GitHub Desktop.
Save eklimcz-zz/55bda51a8a72b841dd36 to your computer and use it in GitHub Desktop.
Get Accerlerometer values
//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