Skip to content

Instantly share code, notes, and snippets.

@markreale
Created May 28, 2012 10:53
Show Gist options
  • Save markreale/2818488 to your computer and use it in GitHub Desktop.
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
/***********************************************
* *
* 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