Forked from addisonhall/check-size-and-orientation.js
Created
January 16, 2017 11:28
-
-
Save umkasanki/16ae9193c9c86e398ea8efcee4cf0e4e 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