Last active
January 16, 2017 11:28
-
-
Save addisonhall/1ab5ef6d5126ca034916 to your computer and use it in GitHub Desktop.
Get screen width, height, and orientation
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
// ---------------------------------------------- | |
// Detect screen orientation | |
// ---------------------------------------------- | |
var deviceOrientation = ''; // Declare globally to use throughout | |
function detectOrientation () { | |
var windowWidth = $(window).height(); | |
var windowHeight = $(window).width(); | |
if (windowWidth > windowHeight) { | |
deviceOrientation = 'landscape'; | |
} else { | |
deviceOrientation = 'portrait'; | |
} | |
} | |
window.addEventListener('resize', function () { | |
detectOrientation(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment