Jquery detect orientation change
Detect a orientation change of portable device with jQuery:
function orient() {
var mobh1 = jQuery(window).height();
var mobw1 = jQuery(window).width();
if(mobh1 > mobw1) {
pos = 1;
} else {
pos = 2;
}
}
jQuery(document).ready(function () {
mobmenu();
orient();
pos1 = pos ;
});
jQuery(window).resize(function () {
orient();
if(pos1 == pos) {
/* some logic if orientation is the same */
} else {
/* some logic if orientation is changed */
pos1 = pos ;
}
});





No comments