Skip to content

Instantly share code, notes, and snippets.

@robbestad
Created June 30, 2013 20:14
Show Gist options
  • Save robbestad/5896684 to your computer and use it in GitHub Desktop.
Save robbestad/5896684 to your computer and use it in GitHub Desktop.
Javascript action on orientation change
window.onorientationchange = function(){
var orientation = window.orientation;
// Look at the value of window.orientation:
if (orientation === 0){
// iPad is in Portrait mode.
}
else if (orientation === 90){
// iPad is in Landscape mode. The screen is turned to the left.
}
else if (orientation === -90){
// iPad is in Landscape mode. The screen is turned to the right.
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment