tencent.jquery.pix.component 1.0.86 → 1.0.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/change.md +4 -0
- package/components/banner/banner.js +55 -8
- package/components/waterfallv2/waterfallv2.js +279 -0
- package/package.json +1 -1
package/change.md
CHANGED
|
@@ -9,7 +9,7 @@ let $ = null;
|
|
|
9
9
|
* @constructor
|
|
10
10
|
* @param {object} options 选项
|
|
11
11
|
* @param {string} options.container 容器元素的jquery选择器
|
|
12
|
-
* @param {Array<{url: string, title: string}>} options.list 轮播图列表, url 为图片背景, title
|
|
12
|
+
* @param {Array<{url: string, title: string, imgObj?: any}>} options.list 轮播图列表, url 为图片背景, title 为图片标题, imgObj 为可选的图片对象引用,若提供则优先作为背景图使用
|
|
13
13
|
* @param {number} [options.index=0] 轮播图初始位置
|
|
14
14
|
* @param {boolean} [options.isTitleEnabled=true] 是否启用标题、翻页栏
|
|
15
15
|
* @param {number} [options.durationMs=0] 轮播图切换时间间隔,单位毫秒,0表示不自动轮播,默认为 0
|
|
@@ -28,6 +28,8 @@ export function Banner(options = {}) {
|
|
|
28
28
|
this.options.durationMs = Number(options.durationMs || 0) || 0;
|
|
29
29
|
this.options.dragThreshold = Number(options.dragThreshold || 0.2) || 0.2;
|
|
30
30
|
this.index = Number(options.index || 0) || 0;
|
|
31
|
+
// 用于保存 options.list 中每一项对应的 imgObj(按 list 索引存储),避免依赖 jQuery 的 data 功能
|
|
32
|
+
this.imgObjMap = {};
|
|
31
33
|
if (typeof options.renderCallback === 'function') {
|
|
32
34
|
this.options.isTitleEnabled = false;
|
|
33
35
|
}
|
|
@@ -176,6 +178,14 @@ Banner.prototype.createHtml = function () {
|
|
|
176
178
|
this.currentTranslate = -signWidth * (this.index + 1)
|
|
177
179
|
$inner.width(allWidth).css('transform', `translateX(${this.currentTranslate}px)`)
|
|
178
180
|
|
|
181
|
+
// 重置 imgObj 映射表,按 list 的索引保存 imgObj 引用
|
|
182
|
+
this.imgObjMap = {};
|
|
183
|
+
for (let i = 0; i < len; i++) {
|
|
184
|
+
if (this.options.list[i].imgObj) {
|
|
185
|
+
this.imgObjMap[i] = this.options.list[i].imgObj;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
179
189
|
// 加第0个位置
|
|
180
190
|
$inner.append(`<div class="banner-inner-li" data-background-url="${this.options.list[len - 1].url}" style="width:${this.signWidth}px;">
|
|
181
191
|
</div>
|
|
@@ -421,33 +431,70 @@ Banner.prototype.normalizeTranslate = async function () {
|
|
|
421
431
|
}
|
|
422
432
|
|
|
423
433
|
/**
|
|
424
|
-
*
|
|
434
|
+
* 应用背景图到指定元素,若存在对应的 imgObj 则优先使用,否则使用 data-background-url
|
|
435
|
+
* @param {jQuery} $item 目标元素
|
|
436
|
+
* @param {object} imgObj 可选的图片对象引用
|
|
437
|
+
*/
|
|
438
|
+
function applyBackgroundImage($item, imgObj) {
|
|
439
|
+
if (imgObj) {
|
|
440
|
+
// 优先使用 imgObj 作为背景图引用,兼容 Image 实例、{url:''}、以及直接为字符串等形式
|
|
441
|
+
const src = imgObj.src || imgObj.url || imgObj;
|
|
442
|
+
$item.css('background-image', `url(${src})`);
|
|
443
|
+
} else {
|
|
444
|
+
$item.css('background-image', `url(${$item.attr('data-background-url')})`);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* 根据 inner 中的子元素下标,换算成 options.list 的索引
|
|
450
|
+
* 由于 inner 首尾各有一个循环占位,所以:
|
|
451
|
+
* childIdx === 0 对应 list[len-1]
|
|
452
|
+
* childIdx === len+1 对应 list[0]
|
|
453
|
+
* 其余 对应 list[childIdx - 1]
|
|
454
|
+
* @param {number} childIdx inner 的子元素下标
|
|
455
|
+
* @param {number} len options.list 的长度
|
|
456
|
+
* @returns {number} options.list 的索引
|
|
457
|
+
*/
|
|
458
|
+
function childIdxToListIdx(childIdx, len) {
|
|
459
|
+
if (childIdx === 0) return len - 1;
|
|
460
|
+
if (childIdx === len + 1) return 0;
|
|
461
|
+
return childIdx - 1;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* 加载所有背景图片,优先使用imgObj,否则使用data-background-url属性
|
|
425
466
|
*/
|
|
426
467
|
Banner.prototype.loadAllBackgrounds = function () {
|
|
427
|
-
this
|
|
428
|
-
|
|
468
|
+
const len = this.options.list.length;
|
|
469
|
+
const imgObjMap = this.imgObjMap || {};
|
|
470
|
+
this.$inner.children().each(function (childIdx) {
|
|
471
|
+
const listIdx = childIdxToListIdx(childIdx, len);
|
|
472
|
+
applyBackgroundImage($(this), imgObjMap[listIdx]);
|
|
429
473
|
});
|
|
430
474
|
// console.log('banner images loaded');
|
|
431
475
|
}
|
|
432
476
|
|
|
433
477
|
/**
|
|
434
|
-
*
|
|
478
|
+
* 加载背景图片,优先使用imgObj,否则使用data-background-url属性
|
|
435
479
|
* @param {number} pos 为加载的图片编号,取值[0, len),如果为0或len-1,会同时加载滚动占位的图片
|
|
436
480
|
*/
|
|
437
481
|
Banner.prototype.loadBackground = function (pos) {
|
|
438
482
|
console.log('loadBackground pos === ', pos);
|
|
483
|
+
const imgObjMap = this.imgObjMap || {};
|
|
439
484
|
let $item = this.$inner.children().eq(pos + 1);
|
|
440
|
-
$item
|
|
485
|
+
applyBackgroundImage($item, imgObjMap[pos]);
|
|
441
486
|
|
|
442
487
|
// 加载滚动占位的图片
|
|
443
488
|
if (pos === 0) {
|
|
444
489
|
$item = this.$inner.children().eq(this.options.list.length + 1);
|
|
445
|
-
|
|
490
|
+
// inner 末位占位对应 list[0]
|
|
491
|
+
applyBackgroundImage($item, imgObjMap[0]);
|
|
446
492
|
}
|
|
447
493
|
|
|
448
494
|
if (pos === this.options.list.length - 1) {
|
|
449
495
|
$item = this.$inner.children().eq(0);
|
|
450
|
-
|
|
496
|
+
// inner 首位占位对应 list[len-1]
|
|
497
|
+
applyBackgroundImage($item, imgObjMap[this.options.list.length - 1]);
|
|
451
498
|
}
|
|
452
499
|
}
|
|
453
500
|
|
|
@@ -48,6 +48,8 @@ const DEFAULTS = {
|
|
|
48
48
|
showLoading: null, // 展示loading的回调函数 params:$node
|
|
49
49
|
hideLoading: null, // 隐藏loading的回调函数
|
|
50
50
|
createLoading: null, // 创建loading的回调函数
|
|
51
|
+
createDropDown: null, // 创建下拉时展现出来的元素的回调函数 params:$node
|
|
52
|
+
dropDownCall: null, // 当下拉位置超过50%时触发的有效下拉回调函数
|
|
51
53
|
};
|
|
52
54
|
|
|
53
55
|
export function Waterfallv2(optionsInput = {}) {
|
|
@@ -199,6 +201,222 @@ Waterfallv2.prototype.init = function (optionsMain = null) {
|
|
|
199
201
|
}
|
|
200
202
|
});
|
|
201
203
|
|
|
204
|
+
const $child = $container.children();
|
|
205
|
+
// 给child容器绑定一个下拉事件
|
|
206
|
+
// 仅当 $scrollDom.scrollTop() === 0 时,才会跟随手指下拉产生 translateY 位移
|
|
207
|
+
// 松手后以过渡动画自然恢复到 translateY(0)
|
|
208
|
+
let pullStartY = 0; // 触摸起始位置
|
|
209
|
+
let pullCurrentY = 0; // 当前位移
|
|
210
|
+
let isPulling = false; // 是否处于下拉中
|
|
211
|
+
let pullReachThreshold = false; // 本次下拉是否已达到有效阈值(超过50%)
|
|
212
|
+
const PULL_DAMPING = 0.7; // 下拉阻尼系数(手指滑动距离 * 系数 = 实际位移),产生橡皮筋效果
|
|
213
|
+
const PULL_DEFAULT_HEIGHT = 200; // 下拉元素默认高度(当 $dropDownNode 不存在或高度为 0 时的兜底值)
|
|
214
|
+
const PULL_RESET_DURATION = 300; // 松手回弹动画时长(ms)
|
|
215
|
+
// 以下 3 个变量会在每次 touchstart 时基于 $dropDownNode 的实际高度动态计算:
|
|
216
|
+
let pullMax = PULL_DEFAULT_HEIGHT * 1.5; // 下拉最大位移(px)
|
|
217
|
+
let pullThreshold = PULL_DEFAULT_HEIGHT; // 有效下拉阈值(超过此距离则视为一次有效下拉)
|
|
218
|
+
let pullHoldOffset = PULL_DEFAULT_HEIGHT; // 触发有效下拉后,松手悬停保持的位移量(保持下拉元素可见)
|
|
219
|
+
|
|
220
|
+
// 下拉保持状态标志(挂在实例上,方便 hideDropDown 等原型方法访问)
|
|
221
|
+
this.isPullHolding = false;
|
|
222
|
+
|
|
223
|
+
// 根据 $dropDownNode 的实际高度动态计算下拉相关的 3 个关键位移值
|
|
224
|
+
// 每次触摸开始时调用,保证拿到最新高度(适应运行时 $dropDownNode 内容变化)
|
|
225
|
+
const recalcPullMetrics = function () {
|
|
226
|
+
let dropH = 0;
|
|
227
|
+
if (self.$dropDownNode && self.$dropDownNode.length) {
|
|
228
|
+
dropH = self.$dropDownNode.height() || 0;
|
|
229
|
+
}
|
|
230
|
+
if (dropH <= 0) {
|
|
231
|
+
dropH = PULL_DEFAULT_HEIGHT;
|
|
232
|
+
}
|
|
233
|
+
pullThreshold = dropH; // 下拉超过 dropDown 完整高度即视为有效
|
|
234
|
+
pullHoldOffset = dropH; // 保持位置刚好让 dropDown 完全可见
|
|
235
|
+
pullMax = dropH * 1.5; // 下拉最大位移为 1.5 倍高度,提供橡皮筋余量
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const pullDomNode = $child.get(0);
|
|
239
|
+
console.log('pullDomNode',pullDomNode);
|
|
240
|
+
|
|
241
|
+
// 通用的 clientY 提取函数:同时兼容触摸事件和鼠标事件
|
|
242
|
+
// - 触摸事件:从 e.touches[0] 或 e.originalEvent.touches[0] 读取
|
|
243
|
+
// - 鼠标事件:直接从 e.clientY 读取
|
|
244
|
+
const getClientY = function (e) {
|
|
245
|
+
if (e.touches && e.touches.length) return e.touches[0].clientY;
|
|
246
|
+
if (e.originalEvent && e.originalEvent.touches && e.originalEvent.touches.length) {
|
|
247
|
+
return e.originalEvent.touches[0].clientY;
|
|
248
|
+
}
|
|
249
|
+
if (typeof e.clientY === 'number') return e.clientY;
|
|
250
|
+
return null;
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
// 创建下拉时展现出来的元素(类似 loading 节点的机制)
|
|
254
|
+
// 节点放置在 $child 内部最顶部,通过 top: -Hpx 自身负偏移隐藏在列表可视区之上;
|
|
255
|
+
// 当 $child 执行 translateY(offset) 向下位移时,该元素会跟随一起下移并自然露出。
|
|
256
|
+
this.$dropDownNode = null;
|
|
257
|
+
if (options.createDropDown && options.createDropDown.constructor === Function) {
|
|
258
|
+
this.$dropDownNode = $(
|
|
259
|
+
`<div class="waterfallv2-dropdown" style="position:absolute;left:0;right:0;bottom:100%;width:100%;"></div>`
|
|
260
|
+
);
|
|
261
|
+
// 插入到 $child 的最前面,使其定位参考 $child($child 为定位上下文时最佳;
|
|
262
|
+
// 若 $child 不是定位元素,也可使用 bottom:100% 让其处于 $child 上方)
|
|
263
|
+
$child.css('position', $child.css('position') === 'static' ? 'relative' : $child.css('position'));
|
|
264
|
+
$child.prepend(this.$dropDownNode);
|
|
265
|
+
options.createDropDown(this.$dropDownNode);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
const onTouchStart = function (e) {
|
|
269
|
+
// 若处于下拉保持状态(等待开发者手动收回),则忽略新的下拉手势
|
|
270
|
+
if (self.isPullHolding) {
|
|
271
|
+
isPulling = false;
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
// 仅当滚动容器已在顶部时才进入下拉模式
|
|
275
|
+
if ($scrollDom.scrollTop() !== 0) {
|
|
276
|
+
isPulling = false;
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const clientY = getClientY(e);
|
|
280
|
+
if (clientY === null) return;
|
|
281
|
+
// 在每次下拉开始时动态获取 $dropDownNode 的实际高度,重新计算下拉关键位移值
|
|
282
|
+
recalcPullMetrics();
|
|
283
|
+
pullStartY = clientY;
|
|
284
|
+
pullCurrentY = 0;
|
|
285
|
+
isPulling = true;
|
|
286
|
+
// 移除过渡,确保跟手
|
|
287
|
+
$child.css('transition', 'none');
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
const onTouchMove = function (e) {
|
|
291
|
+
if (!isPulling) return;
|
|
292
|
+
const clientY = getClientY(e);
|
|
293
|
+
if (clientY === null) return;
|
|
294
|
+
|
|
295
|
+
const dy = clientY - pullStartY;
|
|
296
|
+
|
|
297
|
+
// 仅响应下拉方向
|
|
298
|
+
if (dy <= 0) {
|
|
299
|
+
pullCurrentY = 0;
|
|
300
|
+
$child.css('transform', 'translateY(0px)');
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// 若在下拉过程中滚动位置不为 0(例如系统反弹),则中断下拉
|
|
305
|
+
if ($scrollDom.scrollTop() > 0) {
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// 阻尼衰减 + 最大位移限制
|
|
310
|
+
let offset = dy * PULL_DAMPING;
|
|
311
|
+
|
|
312
|
+
if (offset > pullMax) offset = pullMax;
|
|
313
|
+
pullCurrentY = offset;
|
|
314
|
+
|
|
315
|
+
// 判断是否达到有效下拉阈值(只要过程中曾经超过阈值即视为达到)
|
|
316
|
+
|
|
317
|
+
if (offset >= pullThreshold) {
|
|
318
|
+
|
|
319
|
+
pullReachThreshold = true;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// 在模拟器下 下拉元素还有个默认下滑,这里相对再减去一点值
|
|
323
|
+
$child.css('transform', 'translateY(' + offset * 0.8 + 'px)');
|
|
324
|
+
|
|
325
|
+
// 处于下拉偏移过程中,阻止原生滚动与橡皮筋效果
|
|
326
|
+
if (e.cancelable) {
|
|
327
|
+
if(e.preventDefault) e.preventDefault();
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
const onTouchEnd = function () {
|
|
332
|
+
if (!isPulling) return;
|
|
333
|
+
isPulling = false;
|
|
334
|
+
|
|
335
|
+
// 本次是否达到有效阈值
|
|
336
|
+
const reached = pullReachThreshold;
|
|
337
|
+
pullReachThreshold = false;
|
|
338
|
+
|
|
339
|
+
if (reached) {
|
|
340
|
+
// === 有效下拉:悬停保持,等待开发者手动调用 hideDropDown() 收回 ===
|
|
341
|
+
// 悬停保持位移:使用 touchstart 时动态计算出的 pullHoldOffset(基于 $dropDownNode 实际高度)
|
|
342
|
+
const holdOffset = pullHoldOffset;
|
|
343
|
+
|
|
344
|
+
// 标记进入保持状态
|
|
345
|
+
self.isPullHolding = true;
|
|
346
|
+
|
|
347
|
+
// 以过渡动画平滑过渡到保持位置
|
|
348
|
+
$child.css('transition', 'transform ' + PULL_RESET_DURATION + 'ms ease-out');
|
|
349
|
+
$child.css('transform', 'translateY(' + holdOffset + 'px)');
|
|
350
|
+
|
|
351
|
+
// 动画结束后清理 transition
|
|
352
|
+
setTimeout(function () {
|
|
353
|
+
$child.css('transition', '');
|
|
354
|
+
pullCurrentY = holdOffset;
|
|
355
|
+
}, PULL_RESET_DURATION);
|
|
356
|
+
|
|
357
|
+
// 触发 dropDownCall 回调(在进入保持状态后回调,便于开发者在回调内部发起请求,
|
|
358
|
+
// 完成后调用 self.hideDropDown() 收回下拉)
|
|
359
|
+
if (options.dropDownCall && options.dropDownCall.constructor === Function) {
|
|
360
|
+
try {
|
|
361
|
+
options.dropDownCall(self.$dropDownNode);
|
|
362
|
+
} catch (err) {
|
|
363
|
+
console.error('Waterfallv2: dropDownCall error', err);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// === 未达到阈值:按原逻辑自然回弹到 0 ===
|
|
370
|
+
$child.css('transition', 'transform ' + PULL_RESET_DURATION + 'ms ease-out');
|
|
371
|
+
$child.css('transform', 'translateY(0px)');
|
|
372
|
+
|
|
373
|
+
// 动画结束后清理 transition,避免影响后续其他 transform 修改
|
|
374
|
+
setTimeout(function () {
|
|
375
|
+
$child.css('transition', '');
|
|
376
|
+
pullCurrentY = 0;
|
|
377
|
+
}, PULL_RESET_DURATION);
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
// 桌面端鼠标事件支持:按照触摸事件的同样规律实现鼠标拖拽下拉
|
|
381
|
+
// mousedown / mousemove / mouseup 均绑定在 pullDomNode 上
|
|
382
|
+
// 由于鼠标可能拖出 pullDomNode 边界,额外绑定 mouseleave 作为兼底中断(视同松手)
|
|
383
|
+
const onMouseMove = function (e) {
|
|
384
|
+
onTouchMove(e);
|
|
385
|
+
};
|
|
386
|
+
const onMouseUp = function (e) {
|
|
387
|
+
onTouchEnd(e);
|
|
388
|
+
};
|
|
389
|
+
const onMouseLeave = function (e) {
|
|
390
|
+
// 拖拽过程中移出 pullDomNode 时视为松手,触发回弹或保持逻辑
|
|
391
|
+
if (isPulling) {
|
|
392
|
+
onTouchEnd(e);
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
const onMouseDown = function (e) {
|
|
396
|
+
onTouchStart(e);
|
|
397
|
+
};
|
|
398
|
+
// 小应用环境只支持mousedown的鼠标点击类型事件,不支持touch事件
|
|
399
|
+
if (pullDomNode) {
|
|
400
|
+
pullDomNode.addEventListener('mousedown', onMouseDown);
|
|
401
|
+
pullDomNode.addEventListener('mousemove', onMouseMove);
|
|
402
|
+
pullDomNode.addEventListener('mouseup', onMouseUp);
|
|
403
|
+
pullDomNode.addEventListener('mouseleave', onMouseLeave);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// 保存引用,便于 destroy 时解绑;同时供 hideDropDown 原型方法使用
|
|
407
|
+
this._pullHandlers = {
|
|
408
|
+
$child: $child,
|
|
409
|
+
node: pullDomNode,
|
|
410
|
+
onTouchStart: onTouchStart,
|
|
411
|
+
onTouchMove: onTouchMove,
|
|
412
|
+
onTouchEnd: onTouchEnd,
|
|
413
|
+
onMouseDown: onMouseDown,
|
|
414
|
+
onMouseMove: onMouseMove,
|
|
415
|
+
onMouseUp: onMouseUp,
|
|
416
|
+
onMouseLeave: onMouseLeave,
|
|
417
|
+
resetDuration: PULL_RESET_DURATION,
|
|
418
|
+
};
|
|
419
|
+
|
|
202
420
|
this.scrollTop = $scrollDom.scrollTop(); // 当前滚动位置
|
|
203
421
|
|
|
204
422
|
// 首次渲染
|
|
@@ -1372,10 +1590,69 @@ Waterfallv2.prototype.setScrollHeight = function () {
|
|
|
1372
1590
|
$container.find('.waterfallv2-list-scroll').css('height', h + 'px');
|
|
1373
1591
|
}
|
|
1374
1592
|
|
|
1593
|
+
/**
|
|
1594
|
+
* 手动收回下拉元素(供开发者调用)
|
|
1595
|
+
* 使用场景:触发 dropDownCall 后,$child 悬停保持在可见位置,开发者在异步操作(如刷新数据)完成后,
|
|
1596
|
+
* 调用此方法把下拉元素自然退回到初始位置。
|
|
1597
|
+
* @param {Function} [callback] - 回弹动画完成后的回调(可选)
|
|
1598
|
+
*/
|
|
1599
|
+
Waterfallv2.prototype.hideDropDown = function (callback) {
|
|
1600
|
+
// 未处于保持状态时,直接回调并返回(空操作)
|
|
1601
|
+
if (!this.isPullHolding) {
|
|
1602
|
+
if (callback && callback.constructor === Function) callback();
|
|
1603
|
+
return;
|
|
1604
|
+
}
|
|
1605
|
+
|
|
1606
|
+
const handlers = this._pullHandlers;
|
|
1607
|
+
if (!handlers || !handlers.$child || !handlers.$child.length) {
|
|
1608
|
+
this.isPullHolding = false;
|
|
1609
|
+
if (callback && callback.constructor === Function) callback();
|
|
1610
|
+
return;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
const $child = handlers.$child;
|
|
1614
|
+
const duration = handlers.resetDuration || 300;
|
|
1615
|
+
|
|
1616
|
+
// 以过渡动画自然回到 0
|
|
1617
|
+
$child.css('transition', 'transform ' + duration + 'ms ease-out');
|
|
1618
|
+
$child.css('transform', 'translateY(0px)');
|
|
1619
|
+
|
|
1620
|
+
const self = this;
|
|
1621
|
+
setTimeout(function () {
|
|
1622
|
+
$child.css('transition', '');
|
|
1623
|
+
self.isPullHolding = false;
|
|
1624
|
+
if (callback && callback.constructor === Function) callback();
|
|
1625
|
+
}, duration);
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1375
1628
|
// 销毁自己
|
|
1376
1629
|
Waterfallv2.prototype.destroy = function () {
|
|
1377
1630
|
const options = this.options;
|
|
1378
1631
|
const $container = $(options.container);
|
|
1632
|
+
|
|
1633
|
+
// 解绑下拉事件监听器
|
|
1634
|
+
if (this._pullHandlers && this._pullHandlers.node) {
|
|
1635
|
+
const h = this._pullHandlers;
|
|
1636
|
+
h.node.removeEventListener('touchstart', h.onTouchStart);
|
|
1637
|
+
h.node.removeEventListener('touchmove', h.onTouchMove);
|
|
1638
|
+
h.node.removeEventListener('touchend', h.onTouchEnd);
|
|
1639
|
+
h.node.removeEventListener('touchcancel', h.onTouchEnd);
|
|
1640
|
+
// 解绑鼠标事件(均绑在 pullDomNode 上)
|
|
1641
|
+
if (h.onMouseDown) {
|
|
1642
|
+
h.node.removeEventListener('mousedown', h.onMouseDown);
|
|
1643
|
+
}
|
|
1644
|
+
if (h.onMouseMove) {
|
|
1645
|
+
h.node.removeEventListener('mousemove', h.onMouseMove);
|
|
1646
|
+
}
|
|
1647
|
+
if (h.onMouseUp) {
|
|
1648
|
+
h.node.removeEventListener('mouseup', h.onMouseUp);
|
|
1649
|
+
}
|
|
1650
|
+
if (h.onMouseLeave) {
|
|
1651
|
+
h.node.removeEventListener('mouseleave', h.onMouseLeave);
|
|
1652
|
+
}
|
|
1653
|
+
this._pullHandlers = null;
|
|
1654
|
+
}
|
|
1655
|
+
|
|
1379
1656
|
$container.html('');
|
|
1380
1657
|
this.activeNodes.clear();
|
|
1381
1658
|
this.allReadyNodes.clear();
|
|
@@ -1388,7 +1665,9 @@ Waterfallv2.prototype.destroy = function () {
|
|
|
1388
1665
|
this.renderIndex = 0;
|
|
1389
1666
|
this.scrollTop = 0;
|
|
1390
1667
|
this.isShowLoading = false;
|
|
1668
|
+
this.isPullHolding = false;
|
|
1391
1669
|
this.$loadingNode = null;
|
|
1670
|
+
this.$dropDownNode = null;
|
|
1392
1671
|
this.$scrollDom = null;
|
|
1393
1672
|
}
|
|
1394
1673
|
|