Skip to content

Instantly share code, notes, and snippets.

@umkasanki
Forked from addisonhall/detect-orientation.js
Created January 16, 2017 11:30
Show Gist options
  • Save umkasanki/b2bc06c3498e275487dd0c4f43a44aa9 to your computer and use it in GitHub Desktop.
Save umkasanki/b2bc06c3498e275487dd0c4f43a44aa9 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