Skip to content

Instantly share code, notes, and snippets.

@kevin-smets
Created June 12, 2013 20:01
Show Gist options
  • Save kevin-smets/5768594 to your computer and use it in GitHub Desktop.
Save kevin-smets/5768594 to your computer and use it in GitHub Desktop.
mobile webkit landscape locking hack
$(window).bind("orientationchange", ->
$scope.orientation = window.orientation
$(document.body).css({
width: $(window).width()
height: $(window).height()
})
if window.orientation % 180 is 0
rotation = "rotate(-90deg)"
if window.orientation > 0
rotation = "rotate(90deg)"
$(document.body).css({
'-webkit-transition': "all 1s ease-in-out"
'-webkit-transform-origin': ""
'-webkit-transform': rotation
width: $(window).height()
height: $(window).width()
})
else
$(document.body).css("-webkit-transform-origin", "").css "-webkit-transform", ""
).trigger "orientationchange"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment