Authored by ccbikai

侧边栏点击当前栏目不刷新

@@ -49,8 +49,7 @@ navHammer.on('tap', function(event) { @@ -49,8 +49,7 @@ navHammer.on('tap', function(event) {
49 return false; 49 return false;
50 }); 50 });
51 51
52 -mobileWrapHammer = new Hammer($('.mobile-wrap')[0]);  
53 -mobileWrapHammer.on('tap', function(e) { 52 +function hideSideBar() {
54 if ($mobileWrap.hasClass('menu-open')) { 53 if ($mobileWrap.hasClass('menu-open')) {
55 $mobileWrap.removeClass('menu-open'); 54 $mobileWrap.removeClass('menu-open');
56 $overlay.css('opacity', 0); 55 $overlay.css('opacity', 0);
@@ -63,9 +62,14 @@ mobileWrapHammer.on('tap', function(e) { @@ -63,9 +62,14 @@ mobileWrapHammer.on('tap', function(e) {
63 setTimeout(function() { 62 setTimeout(function() {
64 $('.overlay').hide(); 63 $('.overlay').hide();
65 }, 300); 64 }, 300);
66 - e.srcEvent.stopPropagation();  
67 - return false;  
68 } 65 }
  66 +}
  67 +
  68 +mobileWrapHammer = new Hammer($('.mobile-wrap')[0]);
  69 +mobileWrapHammer.on('tap', function(e) {
  70 + hideSideBar();
  71 + e.srcEvent.stopPropagation();
  72 + return false;
69 }); 73 });
70 74
71 //点击一级导航,弹出二级导航 75 //点击一级导航,弹出二级导航
@@ -75,6 +79,10 @@ $sideNav.on('touchend', 'li', function (e) { @@ -75,6 +79,10 @@ $sideNav.on('touchend', 'li', function (e) {
75 $(this).find('.sub-nav').addClass('show'); 79 $(this).find('.sub-nav').addClass('show');
76 } 80 }
77 e.stopPropagation(); 81 e.stopPropagation();
  82 + if (e.target.pathname === location.pathname) {
  83 + hideSideBar();
  84 + return false;
  85 + }
78 }); 86 });
79 87
80 //返回一级导航,收起二级导航 88 //返回一级导航,收起二级导航