Skip to content

Instantly share code, notes, and snippets.

@exonen
Created September 5, 2013 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save exonen/6455325 to your computer and use it in GitHub Desktop.
Save exonen/6455325 to your computer and use it in GitHub Desktop.
Orientation
// Detect whether device supports orientationchange event, otherwise fall back to
// the resize event.
var supportsOrientationChange = 'onorientationchange' in window,
orientationEvent = supportsOrientationChange ? 'orientationchange' : 'resize';
window.addEventListener(orientationEvent, function() {
window.alert('HOLY ROTATING SCREENS BATMAN:' + window.orientation + ' ' + screen.width);
}, false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment