>  기사  >  웹 프론트엔드  >  Node.js는 수평 및 수직 화면을 결정하고 브라우저 슬라이더 example_javascript 기술을 비활성화합니다.

Node.js는 수평 및 수직 화면을 결정하고 브라우저 슬라이더 example_javascript 기술을 비활성화합니다.

WBOY
WBOY원래의
2016-05-16 16:50:391390검색
코드 복사 코드는 다음과 같습니다.

var $horizontal = $('.horizontal_screen'); //가로 모드 프롬프트 스타일 사용자 정의 가능
var $document = $(document) ;
var PreventDefault = function(e) {
e.preventDefault()
}; = function(e) {
$document.on('touchstart touchmove', PreventDefault);
}
var touchend = function(e) {
$document.off('touchstart touchmove' , PreventDefault)
};

function listening(type){
if('add' == type){
//세로 모드
$horizontal.addClass(' hide');
$document.off('touchstart', touchstart);
$document.off('touchend', touchend)
}else{
//가로 모드
$horizontal.removeClass('hide');
$document.on('touchstart', touchstart)
$document.on('touchend', touchend)
}
}
function OrientalChange(){
switch(window.orientation) {
//세로 모드
case 0:
case 180:
listener('add')
break;
//가로 모드
case -90:
case 90:
listener('remove')
break
}
}

$ (window).on("onorientationchange" in window ? "orientationchange" : "resize", orientationChange)

$document.ready(function(){
//가로 모드에서 인터페이스에 진입하면, 프롬프트는 세로 화면만 지원합니다.
if(window.orientation == 90 || window.orientation == -90){
listener('remove');
}
}); >
성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.