Skip to content

Instantly share code, notes, and snippets.

@solanoize
Created March 10, 2023 01:44
Show Gist options
  • Select an option

  • Save solanoize/5d89a1faa0ee22db270ba33cd5dd7b7b to your computer and use it in GitHub Desktop.

Select an option

Save solanoize/5d89a1faa0ee22db270ba33cd5dd7b7b to your computer and use it in GitHub Desktop.
function getWindowDims() {
let docs = document,
win = window;
let docsEl = (docs.compatMode && docs.compatMode === 'CSS1Compat') ?
docs.documentElement : docs.body;
let width = docsEl.clientWidth;
let height = docsEl.clientHeight;
if (win.innerWidth && width > win.innerWidth) {
width = win.innerWidth;
height = win.innerHeight;
}
return {
width: width,
height: height
};
}
let win = getWindowDims();
console.log(win);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment