tencent.jquery.pix.component 1.0.64 → 1.0.66
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.
|
@@ -42,6 +42,8 @@ export function Waterfall(optionsInput = {}) {
|
|
|
42
42
|
|
|
43
43
|
this.$loadingNode = null;
|
|
44
44
|
|
|
45
|
+
this.isShowLoading = false; // 是否展示loading
|
|
46
|
+
|
|
45
47
|
|
|
46
48
|
// 间隔字符串转数字
|
|
47
49
|
if (options.columnGap.constructor === String) {
|
|
@@ -125,6 +127,7 @@ Waterfall.prototype.init = function () {
|
|
|
125
127
|
const self = this;
|
|
126
128
|
const options = this.options;
|
|
127
129
|
const $container = $(options.container);
|
|
130
|
+
const $scrollDom = options.scrollDom ? $(options.scrollDom) : $container;
|
|
128
131
|
|
|
129
132
|
this.nodePool = []; // DOM 节点池
|
|
130
133
|
this.activeNodes = new Map(); // 当前活跃节点(索引 -> DOM)
|
|
@@ -140,6 +143,7 @@ Waterfall.prototype.init = function () {
|
|
|
140
143
|
|
|
141
144
|
|
|
142
145
|
// 如果有定义loading函数 那么创建一个loading节点元素
|
|
146
|
+
console.log('options.createLoading', options.createLoading)
|
|
143
147
|
if (options.createLoading) {
|
|
144
148
|
this.$loadingNode = $(
|
|
145
149
|
`<div class="waterfall-loading" style="transform: translate(0px, -99999px)"></div>`
|
|
@@ -150,7 +154,7 @@ Waterfall.prototype.init = function () {
|
|
|
150
154
|
}
|
|
151
155
|
|
|
152
156
|
// 绑定滚动事件(节流处理)
|
|
153
|
-
$
|
|
157
|
+
$scrollDom.off().on('scroll', function () {
|
|
154
158
|
self.scrollTop = $(this).scrollTop();
|
|
155
159
|
|
|
156
160
|
window.requestAnimationFrame(() => {
|
|
@@ -162,7 +166,7 @@ Waterfall.prototype.init = function () {
|
|
|
162
166
|
}
|
|
163
167
|
});
|
|
164
168
|
|
|
165
|
-
this.scrollTop = $
|
|
169
|
+
this.scrollTop = $scrollDom.scrollTop(); // 当前滚动位置
|
|
166
170
|
|
|
167
171
|
// 首次渲染
|
|
168
172
|
self.updateVisibleItems();
|
|
@@ -417,8 +421,9 @@ Waterfall.prototype.createCards = function ({ end, dataId = -1 }) {
|
|
|
417
421
|
|
|
418
422
|
// 如果没有更多数据需要渲染
|
|
419
423
|
if (nextDataId === null) {
|
|
420
|
-
const maxHeight = this.getMaxHeight();
|
|
421
|
-
$container.find('.waterfall-list-scroll').css('height', maxHeight + options.marginBottom + 'px');
|
|
424
|
+
// const maxHeight = this.getMaxHeight();
|
|
425
|
+
// $container.find('.waterfall-list-scroll').css('height', maxHeight + options.marginBottom + 'px');
|
|
426
|
+
this.setScrollHeight();
|
|
422
427
|
return;
|
|
423
428
|
}
|
|
424
429
|
|
|
@@ -429,8 +434,7 @@ Waterfall.prototype.createCards = function ({ end, dataId = -1 }) {
|
|
|
429
434
|
}
|
|
430
435
|
|
|
431
436
|
if (this.renderIndex >= options.data.length) {
|
|
432
|
-
|
|
433
|
-
$container.find('.waterfall-list-scroll').css('height', maxHeight + options.marginBottom + 'px');
|
|
437
|
+
this.setScrollHeight();
|
|
434
438
|
return
|
|
435
439
|
}
|
|
436
440
|
|
|
@@ -514,8 +518,9 @@ Waterfall.prototype.createCards = function ({ end, dataId = -1 }) {
|
|
|
514
518
|
this.createCards({ end });
|
|
515
519
|
});
|
|
516
520
|
} else {
|
|
517
|
-
const maxHeight = this.getMaxHeight();
|
|
518
|
-
$(options.container).find('.waterfall-list-scroll').css('height', maxHeight + options.marginBottom + 'px');
|
|
521
|
+
// const maxHeight = this.getMaxHeight();
|
|
522
|
+
// $(options.container).find('.waterfall-list-scroll').css('height', maxHeight + options.marginBottom + 'px');
|
|
523
|
+
this.setScrollHeight();
|
|
519
524
|
}
|
|
520
525
|
}
|
|
521
526
|
|
|
@@ -695,24 +700,23 @@ Waterfall.prototype.updatePointCards = function () {
|
|
|
695
700
|
|
|
696
701
|
// 展示loading的回调函数
|
|
697
702
|
Waterfall.prototype.showLoading = function (callback = null) {
|
|
703
|
+
this.isShowLoading = true;
|
|
698
704
|
const options = this.options;
|
|
699
705
|
const $container = $(options.container);
|
|
700
706
|
let $node = null
|
|
701
707
|
if (this.$loadingNode) {
|
|
702
708
|
let loadingTop = this.getMaxHeight() + options.rowGap
|
|
703
|
-
let h = loadingTop + this.$loadingNode.height() + options.marginBottom
|
|
704
|
-
|
|
705
709
|
this.$loadingNode.css('transform', `translate(0px,${loadingTop}px)`);
|
|
706
|
-
$(options.container).find('.waterfall-list-scroll').css('height', h + 'px');
|
|
707
|
-
|
|
708
710
|
$node = this.$loadingNode
|
|
709
711
|
}
|
|
710
712
|
|
|
711
713
|
if (callback) callback($node)
|
|
714
|
+
this.setScrollHeight();
|
|
712
715
|
}
|
|
713
716
|
|
|
714
717
|
// 隐藏loading的回调函数
|
|
715
718
|
Waterfall.prototype.hideLoading = function (callback = null) {
|
|
719
|
+
this.isShowLoading = false;
|
|
716
720
|
const options = this.options;
|
|
717
721
|
const $container = $(options.container);
|
|
718
722
|
let $node = null
|
|
@@ -722,19 +726,35 @@ Waterfall.prototype.hideLoading = function (callback = null) {
|
|
|
722
726
|
//如果要设置高度,那么这里判断一下当前是否正在做updata 一般这里被调用时,数据已经读到,在updata的同一时间调用了该函数
|
|
723
727
|
// 如果两个时刻高度是一致的 那么数据就是一致的 这里重新设置回来高度即可
|
|
724
728
|
window.requestAnimationFrame(() => {
|
|
725
|
-
let h2 = this.getMaxHeight() + options.marginBottom
|
|
726
|
-
if (h1 === h2) {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
}
|
|
729
|
+
// let h2 = this.getMaxHeight() + options.marginBottom
|
|
730
|
+
// if (h1 === h2) {
|
|
731
|
+
// const $scroll = $(options.container).find('.waterfall-list-scroll')
|
|
732
|
+
// const h = $scroll.height()
|
|
733
|
+
// if (h !== h1) {
|
|
734
|
+
// $scroll.css('height', h1 + 'px');
|
|
735
|
+
// }
|
|
736
|
+
// }
|
|
737
|
+
this.setScrollHeight();
|
|
733
738
|
})
|
|
734
739
|
$node = this.$loadingNode
|
|
735
740
|
}
|
|
736
741
|
|
|
737
742
|
if (callback) callback($node)
|
|
743
|
+
this.setScrollHeight();
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
// 设置滚动条列表的高度
|
|
747
|
+
Waterfall.prototype.setScrollHeight = function () {
|
|
748
|
+
const options = this.options;
|
|
749
|
+
const $container = $(options.container);
|
|
750
|
+
let h = this.getMaxHeight();
|
|
751
|
+
if (this.isShowLoading === true) {
|
|
752
|
+
if (this.$loadingNode) {
|
|
753
|
+
h += options.rowGap + this.$loadingNode.height();
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
h += options.marginBottom;
|
|
757
|
+
$container.find('.waterfall-list-scroll').css('height', h + 'px');
|
|
738
758
|
}
|
|
739
759
|
|
|
740
760
|
function createDefaultRow({ top, left }) {
|