Last active
January 16, 2017 11:30
-
-
Save addisonhall/4b8cc63ae330d60a6463 to your computer and use it in GitHub Desktop.
Detect screen orientation (landscape or portrait)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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