Skip to content

Instantly share code, notes, and snippets.

@steveosoule
Created June 5, 2013 23:21
Show Gist options
  • Save steveosoule/5718084 to your computer and use it in GitHub Desktop.
Save steveosoule/5718084 to your computer and use it in GitHub Desktop.
JavaScript Device Orientation
// http://daker.me/2013/06/5-html5-javascript-apis-to-keep-an-eye-on.html
if (window.DeviceOrientationEvent) {
window.addEventListener('deviceorientation', function(event) {
var a = event.alpha,
b = event.beta,
g = event.gamma;
console.log('Orientation - Alpha: ' + a + ', Beta: '+ b + ', Gamma: ' + g);
}, false);
} else {
console.log('This device does not support deviceorientation');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment