Skip to content

Instantly share code, notes, and snippets.

@makingthingswork
Last active November 19, 2020 14:32
Show Gist options
  • Save makingthingswork/68f657a5f9fa59c1affab09d0081eb9a to your computer and use it in GitHub Desktop.
Save makingthingswork/68f657a5f9fa59c1affab09d0081eb9a to your computer and use it in GitHub Desktop.
Accurately (and reliably) return the width and height of the viewport
var viewport = function() {
var e = window, a = 'inner';
if (!( 'innerWidth' in window)){
a = 'client';
e = document.documentElement || document.body;
}
return { width : e[a+'Width'], height : e[a+'Height'] };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment