Created
May 23, 2013 00:55
-
-
Save agustibr/5632072 to your computer and use it in GitHub Desktop.
Detect iOS devices orientation with jQuery
This file contains hidden or 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
/* | |
* http://pixelhunter.me/post/28843693624/detect-orientation-jquery | |
*/ | |
function checkMode() { | |
var o = window.orientation; | |
if (o != 90 && o != -90) { | |
// here goes code for portrait... | |
} else { | |
// here goes for landscape... | |
} | |
} | |
// check orientation on page load | |
checkMode(); | |
// listen for orientation changes | |
$(window).bind('orientationchange', function() { | |
checkMode(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment