Created
May 28, 2012 10:53
-
-
Save markreale/2818488 to your computer and use it in GitHub Desktop.
Function to retrieve sizes of Window and Document objects for reference in applications
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 global variables for all of the * | |
* elements that you are going to be using for * | |
* size reference. * | |
* * | |
***********************************************/ | |
var landscape = false, | |
portrait = false, | |
ww,wh,dw,dh; | |
/************************************************ | |
* * | |
* Get the sizes of everything relevent. * | |
* Also determine if the viewport is portrait * | |
* or landscape. * | |
* * | |
************************************************/ | |
function initSizes(){ | |
ww = $(window).width(); | |
wh = $(window).height(); | |
dw = $(document).width(); | |
dh = $(document).height(); | |
if(ww > wh){ | |
landscape = true; | |
portrait = false; | |
} | |
else { | |
landscape = false; | |
portrait = true; | |
} | |
/* Console logs for reference | |
console.log(ww); | |
console.log(wh); | |
console.log(dw); | |
console.log(dh); | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment