3초기억력

jquery 스마트폰 회전시 제어하는 구문 본문

코딩_jquery

jquery 스마트폰 회전시 제어하는 구문

잠수콩 2015. 10. 5. 18:16
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.




제목 : jquery 스마트폰 회전시 제어하는 구문




소스 :



function FNareaRelationListCount(){

var areaRelationL = $('#areaRelationList li').length


var areaRelationMaxh = $("#areaRelationList").height();


var areaRelationN = $("#areaRelationList li").filter(function () {

return $(this).position().top + $(this).height() < areaRelationMaxh;

}).length;


if (areaRelationL > areaRelationN)

{

$('#areaRelationBtn').attr('style', 'display:block');

} else {

$('#areaRelationBtn').attr('style', 'display:none');

}

}



var slope = 0;

var supportsOrientationChange = "onorientationchange" in window,

orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";


window.addEventListener(orientationEvent, function() {

if (slope!=window.orientation){

slope = window.orientation;

if(slope == 90 || slope == -90) {

// 가로상태

FNareaRelationListCount();

}

else {

// 세로상태

FNareaRelationListCount();

}

}

}, false);



내용 :


$(window).trigger("orientationchange");


$(window).on("orientationchange", function(e) {

var orientation = window.orientation;


if (orientation == 90 || orientation == -90) {

//alert("landscape");

FNareaRelationListCount();

} else {

//alert("portrait");

FNareaRelationListCount();

}

});


이걸로도 대체 가능





예제 소스 파일 :


 출처 :  




Comments