Created
August 19, 2014 02:19
-
-
Save jiguang/973039036ca6ca6d6bee to your computer and use it in GitHub Desktop.
orientation change
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
/* | |
**设备旋转提示 | |
*/ | |
$(function(){ | |
var bd = $(document.body); | |
window.addEventListener('onorientationchange' in window ? 'orientationchange' : 'resize', _orientationchange, false); | |
function _orientationchange() { | |
scrollTo(0, 1); | |
switch(window.orientation){ | |
case 0: //横屏 | |
bd.addClass("landscape").removeClass("portrait"); | |
init_pageH(); | |
break; | |
case 180: //横屏 | |
bd.addClass("landscape").removeClass("portrait"); | |
init_pageH(); | |
break; | |
case -90: //竖屏 | |
init_pageH(); | |
//bd.addClass("portrait").removeClass("landscape"); | |
if($(".m-video video")[0]!=undefined && $(".m-video video")[0].paused){ | |
alert("请竖屏查看页面,效果更佳"); | |
}else{ | |
alert("请竖屏查看页面,效果更佳"); | |
} | |
break; | |
case 90: //竖屏 | |
init_pageH(); | |
bd.addClass("portrait").removeClass("landscape"); | |
if($(".m-video video")[0].paused) | |
alert("请竖屏查看页面,效果更佳"); | |
break; | |
} | |
} | |
$(window).on('load',_orientationchange); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment