Created
September 13, 2010 13:52
-
-
Save gcoop/577306 to your computer and use it in GitHub Desktop.
This file contains 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 current_orientation; // Cache orientation. | |
x$('body').orientationchange(function() { | |
var newOrientation; | |
switch (window.orientation) // Switch out the windows orientation | |
{ | |
case 0: | |
case 180: // Upside down. | |
newOrientation = 'portrait'; | |
break; | |
case -90: | |
case 90: | |
newOrientation = 'landscape'; | |
break; | |
} | |
if (current_orientation != newOrientation) // Ensure the new orientation isn't the same as the current. | |
{ | |
x$('body').addClass(newOrientation); | |
x$('body').removeClass(current_orientation); | |
orientation_str = newOrientation; // Cache current orientation for comparison, | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment