tencent.jquery.pix.component 1.0.64 → 1.0.65

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) {
@@ -140,6 +142,7 @@ Waterfall.prototype.init = function () {
140
142
 
141
143
 
142
144
  // 如果有定义loading函数 那么创建一个loading节点元素
145
+ console.log('options.createLoading', options.createLoading)
143
146
  if (options.createLoading) {
144
147
  this.$loadingNode = $(
145
148
  `<div class="waterfall-loading" style="transform: translate(0px, -99999px)"></div>`
@@ -417,8 +420,9 @@ Waterfall.prototype.createCards = function ({ end, dataId = -1 }) {
417
420
 
418
421
  // 如果没有更多数据需要渲染
419
422
  if (nextDataId === null) {
420
- const maxHeight = this.getMaxHeight();
421
- $container.find('.waterfall-list-scroll').css('height', maxHeight + options.marginBottom + 'px');
423
+ // const maxHeight = this.getMaxHeight();
424
+ // $container.find('.waterfall-list-scroll').css('height', maxHeight + options.marginBottom + 'px');
425
+ this.setScrollHeight();
422
426
  return;
423
427
  }
424
428
 
@@ -429,8 +433,7 @@ Waterfall.prototype.createCards = function ({ end, dataId = -1 }) {
429
433
  }
430
434
 
431
435
  if (this.renderIndex >= options.data.length) {
432
- const maxHeight = this.getMaxHeight();
433
- $container.find('.waterfall-list-scroll').css('height', maxHeight + options.marginBottom + 'px');
436
+ this.setScrollHeight();
434
437
  return
435
438
  }
436
439
 
@@ -514,8 +517,9 @@ Waterfall.prototype.createCards = function ({ end, dataId = -1 }) {
514
517
  this.createCards({ end });
515
518
  });
516
519
  } else {
517
- const maxHeight = this.getMaxHeight();
518
- $(options.container).find('.waterfall-list-scroll').css('height', maxHeight + options.marginBottom + 'px');
520
+ // const maxHeight = this.getMaxHeight();
521
+ // $(options.container).find('.waterfall-list-scroll').css('height', maxHeight + options.marginBottom + 'px');
522
+ this.setScrollHeight();
519
523
  }
520
524
  }
521
525
 
@@ -695,24 +699,23 @@ Waterfall.prototype.updatePointCards = function () {
695
699
 
696
700
  // 展示loading的回调函数
697
701
  Waterfall.prototype.showLoading = function (callback = null) {
702
+ this.isShowLoading = true;
698
703
  const options = this.options;
699
704
  const $container = $(options.container);
700
705
  let $node = null
701
706
  if (this.$loadingNode) {
702
707
  let loadingTop = this.getMaxHeight() + options.rowGap
703
- let h = loadingTop + this.$loadingNode.height() + options.marginBottom
704
-
705
708
  this.$loadingNode.css('transform', `translate(0px,${loadingTop}px)`);
706
- $(options.container).find('.waterfall-list-scroll').css('height', h + 'px');
707
-
708
709
  $node = this.$loadingNode
709
710
  }
710
711
 
711
712
  if (callback) callback($node)
713
+ this.setScrollHeight();
712
714
  }
713
715
 
714
716
  // 隐藏loading的回调函数
715
717
  Waterfall.prototype.hideLoading = function (callback = null) {
718
+ this.isShowLoading = false;
716
719
  const options = this.options;
717
720
  const $container = $(options.container);
718
721
  let $node = null
@@ -722,19 +725,35 @@ Waterfall.prototype.hideLoading = function (callback = null) {
722
725
  //如果要设置高度,那么这里判断一下当前是否正在做updata 一般这里被调用时,数据已经读到,在updata的同一时间调用了该函数
723
726
  // 如果两个时刻高度是一致的 那么数据就是一致的 这里重新设置回来高度即可
724
727
  window.requestAnimationFrame(() => {
725
- let h2 = this.getMaxHeight() + options.marginBottom
726
- if (h1 === h2) {
727
- const $scroll = $(options.container).find('.waterfall-list-scroll')
728
- const h = $scroll.height()
729
- if (h !== h1) {
730
- $scroll.css('height', h1 + 'px');
731
- }
732
- }
728
+ // let h2 = this.getMaxHeight() + options.marginBottom
729
+ // if (h1 === h2) {
730
+ // const $scroll = $(options.container).find('.waterfall-list-scroll')
731
+ // const h = $scroll.height()
732
+ // if (h !== h1) {
733
+ // $scroll.css('height', h1 + 'px');
734
+ // }
735
+ // }
736
+ this.setScrollHeight();
733
737
  })
734
738
  $node = this.$loadingNode
735
739
  }
736
740
 
737
741
  if (callback) callback($node)
742
+ this.setScrollHeight();
743
+ }
744
+
745
+ // 设置滚动条列表的高度
746
+ Waterfall.prototype.setScrollHeight = function () {
747
+ const options = this.options;
748
+ const $container = $(options.container);
749
+ let h = this.getMaxHeight();
750
+ if (this.isShowLoading === true) {
751
+ if (this.$loadingNode) {
752
+ h += options.rowGap + this.$loadingNode.height();
753
+ }
754
+ }
755
+ h += options.marginBottom;
756
+ $container.find('.waterfall-list-scroll').css('height', h + 'px');
738
757
  }
739
758
 
740
759
  function createDefaultRow({ top, left }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tencent.jquery.pix.component",
3
- "version": "1.0.64",
3
+ "version": "1.0.65",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [