Skip to content

Instantly share code, notes, and snippets.

@sowasred2012
Last active December 10, 2015 21:28
Show Gist options
  • Save sowasred2012/4495052 to your computer and use it in GitHub Desktop.
Save sowasred2012/4495052 to your computer and use it in GitHub Desktop.
Executes function whenever there's an orientation change (i.e. rotating a smartphone/tablet)
$(window).bind('orientationchange', function(){
// do whatever
});
// The below will give you the current orientation for iOS devices, possible values being 0, 90, -90 or 180 (180 on iPad only)
if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
alert(window.orientation);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment