Last active
November 19, 2020 14:32
-
-
Save makingthingswork/68f657a5f9fa59c1affab09d0081eb9a to your computer and use it in GitHub Desktop.
Accurately (and reliably) return the width and height of the viewport
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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