Skip to content

Instantly share code, notes, and snippets.

@ashhitch
Created January 4, 2018 12:55
Show Gist options
  • Select an option

  • Save ashhitch/8dc37f045961f8e797242c40392b6a49 to your computer and use it in GitHub Desktop.

Select an option

Save ashhitch/8dc37f045961f8e797242c40392b6a49 to your computer and use it in GitHub Desktop.
Angular Get viewport width
getViewport(): any {
let win = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
w = win.innerWidth || e.clientWidth || g.clientWidth,
h = win.innerHeight || e.clientHeight || g.clientHeight;
return {width: w, height: h};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment