Skip to content

Instantly share code, notes, and snippets.

@addisonhall
Last active January 16, 2017 11:30
Show Gist options
  • Save addisonhall/4b8cc63ae330d60a6463 to your computer and use it in GitHub Desktop.
Save addisonhall/4b8cc63ae330d60a6463 to your computer and use it in GitHub Desktop.
Detect screen orientation (landscape or portrait)
// Declare globally to use throughout
var deviceOrientation = '';
// ----------------------------------------------------
// Detect screen orientation
// ----------------------------------------------------
function detectOrientation() {
var height = $(window).height();
var width = $(window).width();
if(width > height) {
deviceOrientation = 'landscape';
} else {
deviceOrientation = 'portrait';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment