-
-
Save umkasanki/b2bc06c3498e275487dd0c4f43a44aa9 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