|
@@ -71,6 +71,32 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) { |
|
@@ -71,6 +71,32 @@ function setEditModeWithSknId(sknId, isThisGoodSelected) { |
71
|
isSelected = isThisGoodSelected;
|
71
|
isSelected = isThisGoodSelected;
|
72
|
}
|
72
|
}
|
73
|
|
73
|
|
|
|
74
|
+function preventDefault(e) {
|
|
|
75
|
+ console.log(e);
|
|
|
76
|
+ if (e.target.localName === 'ul') return;
|
|
|
77
|
+ e = e || window.event;
|
|
|
78
|
+ if (e.preventDefault)
|
|
|
79
|
+ e.preventDefault();
|
|
|
80
|
+ e.returnValue = false;
|
|
|
81
|
+}
|
|
|
82
|
+
|
|
|
83
|
+function disableScroll(e) {
|
|
|
84
|
+ if (window.addEventListener) // older FF
|
|
|
85
|
+ window.addEventListener('DOMMouseScroll', preventDefault, false);
|
|
|
86
|
+ window.onwheel = preventDefault; // modern standard
|
|
|
87
|
+ window.onmousewheel = document.onmousewheel = preventDefault; // older browsers, IE
|
|
|
88
|
+ window.ontouchmove = preventDefault; // mobile
|
|
|
89
|
+}
|
|
|
90
|
+
|
|
|
91
|
+function enableScroll() {
|
|
|
92
|
+ if (window.removeEventListener)
|
|
|
93
|
+ window.removeEventListener('DOMMouseScroll', preventDefault, false);
|
|
|
94
|
+ window.onmousewheel = document.onmousewheel = null;
|
|
|
95
|
+ window.onwheel = null;
|
|
|
96
|
+ window.ontouchmove = null;
|
|
|
97
|
+ document.onkeydown = null;
|
|
|
98
|
+}
|
|
|
99
|
+
|
74
|
//删除面板
|
100
|
//删除面板
|
75
|
function removePannel() {
|
101
|
function removePannel() {
|
76
|
var $pannel = $('.chose-panel'),
|
102
|
var $pannel = $('.chose-panel'),
|
|
@@ -112,9 +138,7 @@ function disableNumEdit() { |
|
@@ -112,9 +138,7 @@ function disableNumEdit() { |
112
|
|
138
|
|
113
|
|
139
|
|
114
|
function show(html, cb) {
|
140
|
function show(html, cb) {
|
115
|
- var $html = $('html, body');
|
|
|
116
|
-
|
|
|
117
|
- /*var scrollPosition = [
|
141
|
+ var scrollPosition = [
|
118
|
document.documentElement.scrollLeft || document.body.scrollLeft,
|
142
|
document.documentElement.scrollLeft || document.body.scrollLeft,
|
119
|
document.documentElement.scrollTop || document.body.scrollTop
|
143
|
document.documentElement.scrollTop || document.body.scrollTop
|
120
|
],
|
144
|
],
|
|
@@ -124,7 +148,7 @@ function show(html, cb) { |
|
@@ -124,7 +148,7 @@ function show(html, cb) { |
124
|
$html.data('previous-overflow', $html.css('overflow'));
|
148
|
$html.data('previous-overflow', $html.css('overflow'));
|
125
|
$html.css('overflow', 'hidden');
|
149
|
$html.css('overflow', 'hidden');
|
126
|
$html.css('height', '100%');
|
150
|
$html.css('height', '100%');
|
127
|
- window.scrollTo(scrollPosition[0], scrollPosition[1]);*/
|
151
|
+ window.scrollTo(scrollPosition[0], scrollPosition[1]);
|
128
|
|
152
|
|
129
|
if (html) {
|
153
|
if (html) {
|
130
|
$chosePanel.html(html);
|
154
|
$chosePanel.html(html);
|
|
@@ -136,20 +160,22 @@ function show(html, cb) { |
|
@@ -136,20 +160,22 @@ function show(html, cb) { |
136
|
$('.chose-panel').show();
|
160
|
$('.chose-panel').show();
|
137
|
$num = $('#good-num');
|
161
|
$num = $('#good-num');
|
138
|
cbFn = cb;
|
162
|
cbFn = cb;
|
|
|
163
|
+
|
|
|
164
|
+ disableScroll();
|
139
|
}
|
165
|
}
|
140
|
|
166
|
|
141
|
//隐藏当前Panel
|
167
|
//隐藏当前Panel
|
142
|
function hide() {
|
168
|
function hide() {
|
143
|
- $html = $('html, body');
|
|
|
144
|
-
|
|
|
145
|
- /*var $html = $('html, body'),
|
169
|
+ var $html = $('html, body'),
|
146
|
scrollPosition = $html.data('scroll-position');
|
170
|
scrollPosition = $html.data('scroll-position');
|
147
|
|
171
|
|
148
|
// un-lock scroll position
|
172
|
// un-lock scroll position
|
149
|
$html.css('overflow', $html.data('previous-overflow'));
|
173
|
$html.css('overflow', $html.data('previous-overflow'));
|
150
|
$html.css('height', 'auto');
|
174
|
$html.css('height', 'auto');
|
151
|
- window.scrollTo(scrollPosition[0], scrollPosition[1]);*/
|
175
|
+ window.scrollTo(scrollPosition[0], scrollPosition[1]);
|
152
|
$('.chose-panel').hide();
|
176
|
$('.chose-panel').hide();
|
|
|
177
|
+
|
|
|
178
|
+ enableScroll();
|
153
|
}
|
179
|
}
|
154
|
|
180
|
|
155
|
//修改加入购物车的文字和背景
|
181
|
//修改加入购物车的文字和背景
|
|
@@ -231,6 +257,7 @@ function changeColorChosed(newColorIndex) { |
|
@@ -231,6 +257,7 @@ function changeColorChosed(newColorIndex) { |
231
|
|
257
|
|
232
|
init();
|
258
|
init();
|
233
|
|
259
|
|
|
|
260
|
+
|
234
|
$yohoPage.on('touchstart', '.chose-panel', function(e) {
|
261
|
$yohoPage.on('touchstart', '.chose-panel', function(e) {
|
235
|
var $cur = $(e.target);
|
262
|
var $cur = $(e.target);
|
236
|
|
263
|
|
|
@@ -241,6 +268,8 @@ $yohoPage.on('touchstart', '.chose-panel', function(e) { |
|
@@ -241,6 +268,8 @@ $yohoPage.on('touchstart', '.chose-panel', function(e) { |
241
|
//点击蒙版消失
|
268
|
//点击蒙版消失
|
242
|
hide();
|
269
|
hide();
|
243
|
|
270
|
|
|
|
271
|
+ enableScroll();
|
|
|
272
|
+
|
244
|
return false;
|
273
|
return false;
|
245
|
});
|
274
|
});
|
246
|
|
275
|
|