tencent.jquery.pix.component 1.0.63-beta.2 → 1.0.63-beta.3

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.
@@ -576,7 +576,72 @@ Waterfall.prototype.updateData = function (newData) {
576
576
  // this.updatePointCards();
577
577
  }
578
578
 
579
+ // 某个数据进行了UI变更,触发高度重新绘制
580
+ Waterfall.prototype.updateCard = function (data) {
581
+ const options = this.options;
582
+ let dataId = -1;
583
+ if (typeof data === 'number') {
584
+ dataId = data;
585
+ } else {
586
+ for (let i = 0; i < options.data.length; i++) {
587
+ if (options.data[i] === data) {
588
+ dataId = i;
589
+ break;
590
+ }
591
+ }
592
+ }
593
+ if (dataId === -1) {
594
+ // 没有匹配到数据,进行退出
595
+ console.log('Waterfall: Invalid data in options.data');
596
+ return
597
+ }
598
+
599
+ // 从activeNodes中获取该数据的节点
600
+ if (!this.activeNodes.has(dataId)) {
601
+ console.log('Waterfall: Invalid dataId in activeNodes');
602
+ return
603
+ }
579
604
 
605
+ const $node = this.activeNodes.get(dataId);
606
+ const height = $node.height();
607
+ console.log('Waterfall: updateCard height', height);
608
+ // 重新计算该数据所在列的卡片位置
609
+ let needUpdate = false
610
+ const columnItems = this.columnItems;
611
+ for (let i = 0; i < columnItems.length; i++) {
612
+ const column = columnItems[i];
613
+ let bool = false
614
+ let minus = 0
615
+ // 这里为了简化,各列的瀑布流保持不动,只更新各列下节点的top位置,不做节点的跨列位移
616
+ for (let j = 0; j < column.children.length; j++) {
617
+ const row = column.children[j];
618
+ if (row.dataId === dataId) {
619
+ bool = true
620
+ const oldHeight = row.bottom - row.top;
621
+
622
+ console.log('Waterfall: updateCard oldHeight', oldHeight);
623
+ minus = height - oldHeight;
624
+ console.log('Waterfall: updateCard minus', minus);
625
+ if (minus === 0) {
626
+ // 找到了原节点数据,对比后没有变更 那么直接退出
627
+ return;
628
+ }
629
+ needUpdate = true
630
+ row.bottom += minus;
631
+ } else if (minus !== 0) {
632
+ row.top += minus;
633
+ row.bottom += minus;
634
+ }
635
+ }
636
+ if (bool) {
637
+ column.bottom += minus;
638
+ break;
639
+ }
640
+ }
641
+ if (needUpdate) {
642
+ this.updateVisibleItems(true); // 强制更新渲染
643
+ }
644
+ }
580
645
 
581
646
  // 重新计算设置一遍所有的卡片位置
582
647
  Waterfall.prototype.updatePointCards = function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tencent.jquery.pix.component",
3
- "version": "1.0.63-beta.2",
3
+ "version": "1.0.63-beta.3",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [