Created
October 8, 2012 10:33
-
-
Save ambar/3851874 to your computer and use it in GitHub Desktop.
fix iOS6 orientation bug
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
var onOrientationChange, $html = $(document.documentElement) | |
if ('orientation' in window) { | |
onOrientationChange = function() { | |
var classes = { | |
'0': 'portrait', | |
'90': 'landscape landscape-left', | |
'-90': 'landscape landscape-right' | |
} | |
var values = function(o) { | |
return Object.keys(o).map(function (k) { return o[k] }) | |
} | |
$html | |
.removeClass(values(classes).join(' ')) | |
.addClass(classes[window.orientation]) | |
} | |
$(window).on('orientationchange', onOrientationChange) | |
onOrientationChange() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
其他可选:
body > div {overflow-x:hidden}
;