jquery 스마트폰 회전시 제어하는 구문
제목 : 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();
}
});
이걸로도 대체 가능
예제 소스 파일 :
출처 :