Skip to content

Instantly share code, notes, and snippets.

@jorgeortega
Created June 8, 2018 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jorgeortega/fd3292bdcd7be0b49a9bc97f6a34bc25 to your computer and use it in GitHub Desktop.
Save jorgeortega/fd3292bdcd7be0b49a9bc97f6a34bc25 to your computer and use it in GitHub Desktop.
Get viewport dimension
export function getViewportDimensions () {
const w = window
const d = document
const e = d.documentElement
const g = d.getElementsByTagName('body')[0]
const x = w.innerWidth || e.clientWidth || g.clientWidth
const y = w.innerHeight || e.clientHeight || g.clientHeight
return { x, y }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment