Skip to content

Instantly share code, notes, and snippets.

@mfd
Forked from kevin-smets/landscapeLock.coffee
Created July 16, 2016 10:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfd/143cd649005b211738afadac6a7f4538 to your computer and use it in GitHub Desktop.
Save mfd/143cd649005b211738afadac6a7f4538 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