...
|
...
|
@@ -29,16 +29,8 @@ $('.nav-btn').on('touchstart', function(event) { |
|
|
$mobileWrap.addClass('menu-open');
|
|
|
$overlay.show().css('opacity', 0.3);
|
|
|
$sideNav.addClass('on');
|
|
|
event.preventDefault();
|
|
|
event.stopPropagation();
|
|
|
openSideNav = true;
|
|
|
|
|
|
//设置boy高宽,页面不能上下滑动
|
|
|
$('body').css({
|
|
|
height: $(window).height(),
|
|
|
overflow: 'hidden'
|
|
|
});
|
|
|
|
|
|
setTimeout(function() {
|
|
|
$sideNav.css('pointer-events', 'auto');
|
|
|
}, 400);
|
...
|
...
|
@@ -50,13 +42,9 @@ function hideSideBar() { |
|
|
openSideNav = false;
|
|
|
if ($mobileWrap.hasClass('menu-open')) {
|
|
|
$mobileWrap.removeClass('menu-open');
|
|
|
$('.overlay').hide();
|
|
|
$overlay.hide();
|
|
|
$('.sub-nav').removeClass('show');
|
|
|
$sideNav.removeClass('on');
|
|
|
$('body').css({
|
|
|
height: 'auto',
|
|
|
overflow: 'auto'
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -65,6 +53,10 @@ $('.overlay').on('touchstart', function(e) { |
|
|
return false;
|
|
|
});
|
|
|
|
|
|
$sideNav.on('touchmove', function(e) {
|
|
|
return false;
|
|
|
});
|
|
|
|
|
|
//点击一级导航,弹出二级导航
|
|
|
$sideNav.on('touchstart', 'li', function(e) {
|
|
|
if ($(this).find('.sub-nav').size() > 0) {
|
...
|
...
|
@@ -80,9 +72,13 @@ $sideNav.on('touchstart', 'li', function(e) { |
|
|
|
|
|
//返回一级导航,收起二级导航
|
|
|
$subNav.each(function() {
|
|
|
$(this).find('li').eq(0).on('touchstart', function() {
|
|
|
$(this).find('li').eq(0).on('touchend', function() {
|
|
|
$sideNav.css('pointer-events', 'none');
|
|
|
setTimeout(function() {
|
|
|
$sideNav.css('pointer-events', 'auto');
|
|
|
}, 400);
|
|
|
|
|
|
$('.sub-nav').removeClass('show');
|
|
|
return false;
|
|
|
});
|
|
|
}).on('touchstart', function(e) {
|
|
|
if (e.currentTarget !== e.target) {
|
...
|
...
|
@@ -93,6 +89,7 @@ $subNav.each(function() { |
|
|
// 侧边栏点击背景色变化
|
|
|
function highlight($elem) {
|
|
|
$elem.find('li').on('touchstart', function() {
|
|
|
$elem.find('.highlight').removeClass('highlight');
|
|
|
$(this).addClass('highlight');
|
|
|
}).on('touchend touchcancel', function() {
|
|
|
$(this).removeClass('highlight');
|
...
|
...
|
|