Created
January 5, 2013 17:40
-
-
Save valpackett/4462678 to your computer and use it in GitHub Desktop.
Landscape viewport fix (i.e. makes it 1024px on landscape iPad, 480px on landscape iPhone)
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
if (typeof window.orientation !== 'undefined') { | |
var viewport = document.querySelector('meta[name=viewport]'); | |
function isLandscape() { | |
return window.orientation === 90 || window.orientation === -90; | |
} | |
function fixViewport() { | |
if (isLandscape()) { viewport.content = 'width=device-height' } | |
else { viewport.content = 'width=device-width' } | |
} | |
fixViewport(); | |
window.addEventListener('orientationchange', fixViewport); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment