Skip to content

Instantly share code, notes, and snippets.

@Komsomol
Last active August 29, 2015 14:12
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 Komsomol/6137d5e13d3caa7be213 to your computer and use it in GitHub Desktop.
Save Komsomol/6137d5e13d3caa7be213 to your computer and use it in GitHub Desktop.
Check for Window Orientation of mobile devices. Landscape and Portrait.
window.addEventListener('orientationchange', checkPage);
function checkPage(){
switch(window.orientation){
case 90:
currentState = 'landscape';
break;
case 0:
currentState = 'portrait';
break;
}
console.log('change in oreintation', window.orientation, currentState);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment