Created
March 12, 2014 16:27
-
-
Save stefano-bortolotti/9510619 to your computer and use it in GitHub Desktop.
Set screen orientation to the body tag
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
function _getScreenOrientation() { | |
/* | |
returns screen orientation(landscape|portrait) and | |
set the attribute on the body "data-landscape[true|false]" | |
*/ | |
if ( window.orientation == ( -90 || 180 ) ) { | |
document.body.setAttribute('data-landscape', 'true'); | |
return 'landscape'; | |
} | |
else { | |
document.body.setAttribute('data-landscape', 'false'); | |
return 'portrait'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment