4
그래서 세로 또는 가로 방향으로 태블릿을 볼 때 스타일을 변경하는 탐색 메뉴가 있습니다. 마지막 몇 개의 메뉴 항목을 다른 드롭 다운 메뉴로 축소합니다. 그러나 방향 변경시 메뉴가 업데이트되지 않고 새로 고침 후에 만 업데이트됩니다.jquery와 modernizr을 사용한 태블릿 방향 변경
JQuery와 모더 나이저 코드 :
if(Modernizr.mq('(max-device-width: 800px) and (orientation: portrait)')){
// portrait stuff
// unhides last few menu items
$('#menu-primary-items > li:nth-last-child(-n+3)').css('display', 'block');
// remove hide and first child class originally assigned to it from it's ul parent
// then add the more list item to the end of the nav menu
$('.moreItem').removeClass('hide first-child').appendTo('#menu-primary-items');
// grab the last two items of the nav menu and insert into the more list item menu
$('.topNavigation .toplevel').slice(-2).appendTo('.moreMenu');
}
어떤 제안이?
천만에요. 그리고 귀하의 질문에 대답 - 나는 당신이'resize' 이벤트 리스너를 첨부하고 다시'Modernizr.mq'를 할 것을 제안합니다. – ahren