Skip to content

Instantly share code, notes, and snippets.

@fsvehla
Created March 22, 2009 23:52
Show Gist options
  • Save fsvehla/83340 to your computer and use it in GitHub Desktop.
Save fsvehla/83340 to your computer and use it in GitHub Desktop.
var lastKnownOrientation = null;
function rotate() {
if(window.orientation != lastKnownOrientation) {
lastKnownOrientation = window.orientation;
updateRotation();
}
}
function updateRotation() {
if(lastKnownOrientation == 0) {
$('body').attr("class", "h");
} else {
$('body').attr("class", "v");
}
$('#orientation').html("iPhone ist " + lastKnownOrientation + ' Grad gedreht.');
}
$(function() {
rotate();
$(document).resize(function(e) { rotate() });
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment