Created
August 12, 2014 17:57
-
-
Save garystorey/7eff9b5fa709117a4a98 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| /* | |
| * Accurately returns the height and width of the viewport | |
| * much more reliably than simply $(window).height | |
| * | |
| * Source: http://andylangton.co.uk/blog/development/get-viewport-size-width-and-height-javascript | |
| */ | |
| function viewport() { | |
| 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' ] } | |
| } | |
| function is_mobile() { | |
| if (viewport().width < 768) { | |
| return true; | |
| } else { | |
| return false; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment