Created
July 27, 2015 08:32
-
-
Save leonkorteweg/831f3b2fc92b66a1c016 to your computer and use it in GitHub Desktop.
Return width and height of 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
// Get screen dimensions | |
// http://stackoverflow.com/questions/18546067/why-is-the-window-width-smaller-than-the-viewport-width-set-in-media-queries | |
var screenDimensions = 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