Skip to content

Instantly share code, notes, and snippets.

@ambar
Created October 8, 2012 10:33
Show Gist options
  • Save ambar/3851874 to your computer and use it in GitHub Desktop.
Save ambar/3851874 to your computer and use it in GitHub Desktop.
fix iOS6 orientation bug
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()
}
@ambar
Copy link
Author

ambar commented Oct 8, 2012

其他可选:

  • 移除 meta viewport 的 scale 属性;
  • body > div {overflow-x:hidden}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment