|
@@ -24,97 +24,6 @@ var start = 0, |
|
@@ -24,97 +24,6 @@ var start = 0, |
24
|
|
24
|
|
25
|
lazyLoad($('img.lazy'));
|
25
|
lazyLoad($('img.lazy'));
|
26
|
|
26
|
|
27
|
-function preventDefault(e) {
|
|
|
28
|
- e = e || window.event;
|
|
|
29
|
- e.preventDefault && e.preventDefault();
|
|
|
30
|
- e.returnValue = false;
|
|
|
31
|
-}
|
|
|
32
|
-
|
|
|
33
|
-function stopPropagation(e){
|
|
|
34
|
- e = e || window.event;
|
|
|
35
|
- e.stopPropagation && e.stopPropagation();
|
|
|
36
|
- e.cancelBubble = false;
|
|
|
37
|
-}
|
|
|
38
|
-
|
|
|
39
|
-/**function innerScroll(e){
|
|
|
40
|
- // 阻止冒泡到document
|
|
|
41
|
- // document上已经preventDefault
|
|
|
42
|
- stopPropagation(e);
|
|
|
43
|
-
|
|
|
44
|
- var delta = e.wheelDelta || e.detail || 0;
|
|
|
45
|
- var box = $(this).get(0);
|
|
|
46
|
-
|
|
|
47
|
- if($(box).height() + box.scrollTop >= box.scrollHeight){
|
|
|
48
|
- if(delta < 0) {
|
|
|
49
|
- preventDefault(e);
|
|
|
50
|
- return false;
|
|
|
51
|
- }
|
|
|
52
|
- }
|
|
|
53
|
- if(box.scrollTop === 0){
|
|
|
54
|
- if(delta > 0) {
|
|
|
55
|
- preventDefault(e);
|
|
|
56
|
- return false;
|
|
|
57
|
- }
|
|
|
58
|
- }
|
|
|
59
|
- // 会阻止原生滚动
|
|
|
60
|
- // return false;
|
|
|
61
|
-}**/
|
|
|
62
|
-
|
|
|
63
|
-/**var disableScroll = function(){
|
|
|
64
|
- $(document).on('mousewheel', preventDefault);
|
|
|
65
|
- $(document).on('touchmove', preventDefault);
|
|
|
66
|
-};
|
|
|
67
|
-
|
|
|
68
|
-var enableScroll = function(){
|
|
|
69
|
- $(document).off('mousewheel', preventDefault);
|
|
|
70
|
- $(document).off('touchmove', preventDefault);
|
|
|
71
|
-};
|
|
|
72
|
-
|
|
|
73
|
- // 内部可滚
|
|
|
74
|
-$sideNav.on('touchmove mousewheel', stopPropagation);
|
|
|
75
|
-
|
|
|
76
|
-// 外部禁用
|
|
|
77
|
-disableScroll();
|
|
|
78
|
-
|
|
|
79
|
-
|
|
|
80
|
-// 移动端touch重写
|
|
|
81
|
-var startX, startY;
|
|
|
82
|
-$sideNav.on('touchstart', function(e){
|
|
|
83
|
- startX = e.originalEvent.touches[0].pageX;
|
|
|
84
|
- startY = e.originalEvent.touches[0].pageY;
|
|
|
85
|
-});**/
|
|
|
86
|
-
|
|
|
87
|
-// 仿innerScroll方法
|
|
|
88
|
-/**$sideNav.on('touchmove', function(e){
|
|
|
89
|
- e.stopPropagation();
|
|
|
90
|
-
|
|
|
91
|
- var deltaX = e.originalEvent.touches[0].pageX - startX;
|
|
|
92
|
- var deltaY = e.originalEvent.touches[0].pageY - startY;
|
|
|
93
|
-
|
|
|
94
|
- // 只能纵向滚
|
|
|
95
|
- if(Math.abs(deltaY) < Math.abs(deltaX)){
|
|
|
96
|
- e.preventDefault();
|
|
|
97
|
- return false;
|
|
|
98
|
- }
|
|
|
99
|
-
|
|
|
100
|
- var box = $(this).get(0);
|
|
|
101
|
-
|
|
|
102
|
- if($(box).height() + box.scrollTop >= box.scrollHeight){
|
|
|
103
|
- if(deltaY < 0) {
|
|
|
104
|
- e.preventDefault();
|
|
|
105
|
- return false;
|
|
|
106
|
- }
|
|
|
107
|
- }
|
|
|
108
|
- if(box.scrollTop === 0){
|
|
|
109
|
- if(deltaY > 0) {
|
|
|
110
|
- e.preventDefault();
|
|
|
111
|
- return false;
|
|
|
112
|
- }
|
|
|
113
|
- }
|
|
|
114
|
- // 会阻止原生滚动
|
|
|
115
|
- // return false;
|
|
|
116
|
-});**/
|
|
|
117
|
-
|
|
|
118
|
$('.nav-btn').on('touchstart', function(event) {
|
27
|
$('.nav-btn').on('touchstart', function(event) {
|
119
|
$sideNav.css('pointer-events', 'none');
|
28
|
$sideNav.css('pointer-events', 'none');
|
120
|
$mobileWrap.addClass('menu-open');
|
29
|
$mobileWrap.addClass('menu-open');
|
|
@@ -124,12 +33,6 @@ $('.nav-btn').on('touchstart', function(event) { |
|
@@ -124,12 +33,6 @@ $('.nav-btn').on('touchstart', function(event) { |
124
|
event.stopPropagation();
|
33
|
event.stopPropagation();
|
125
|
openSideNav = true;
|
34
|
openSideNav = true;
|
126
|
|
35
|
|
127
|
- //设置boy高宽,页面不能上下滑动
|
|
|
128
|
- $('body').css({
|
|
|
129
|
- height: $(window).height(),
|
|
|
130
|
- overflow: 'hidden'
|
|
|
131
|
- });
|
|
|
132
|
-
|
|
|
133
|
setTimeout(function() {
|
36
|
setTimeout(function() {
|
134
|
$sideNav.css('pointer-events', 'auto');
|
37
|
$sideNav.css('pointer-events', 'auto');
|
135
|
}, 400);
|
38
|
}, 400);
|
|
@@ -144,11 +47,6 @@ function hideSideBar() { |
|
@@ -144,11 +47,6 @@ function hideSideBar() { |
144
|
$('.overlay').hide();
|
47
|
$('.overlay').hide();
|
145
|
$('.sub-nav').removeClass('show');
|
48
|
$('.sub-nav').removeClass('show');
|
146
|
$sideNav.removeClass('on');
|
49
|
$sideNav.removeClass('on');
|
147
|
- $('body').css({
|
|
|
148
|
- height: 'auto',
|
|
|
149
|
- overflow: 'auto'
|
|
|
150
|
- });
|
|
|
151
|
- //enableScroll();
|
|
|
152
|
}
|
50
|
}
|
153
|
}
|
51
|
}
|
154
|
|
52
|
|
|
@@ -157,6 +55,10 @@ $('.overlay').on('touchstart', function(e) { |
|
@@ -157,6 +55,10 @@ $('.overlay').on('touchstart', function(e) { |
157
|
return false;
|
55
|
return false;
|
158
|
});
|
56
|
});
|
159
|
|
57
|
|
|
|
58
|
+$sideNav.on('touchmove', function(e) {
|
|
|
59
|
+ return false;
|
|
|
60
|
+});
|
|
|
61
|
+
|
160
|
//点击一级导航,弹出二级导航
|
62
|
//点击一级导航,弹出二级导航
|
161
|
$sideNav.on('touchend', 'li', function(e) {
|
63
|
$sideNav.on('touchend', 'li', function(e) {
|
162
|
if ($(this).find('.sub-nav').size() > 0) {
|
64
|
if ($(this).find('.sub-nav').size() > 0) {
|