tencent.jquery.pix.component 1.0.67 → 1.0.69

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.
@@ -12,7 +12,7 @@ const DEFAULTS = {
12
12
  marginTop: 0, // 距离顶部距离
13
13
  marginBottom: 12, // 最后一行距离底部距离
14
14
  bufferHeight: '2rem', // 缓冲高度,进行可能的预先添加高度
15
- startPoints: [], // 起始点坐标
15
+ startPoints: [], // 起始点距离
16
16
  data: [], // 数据源
17
17
  container: '', // 容器元素
18
18
  renderItem(data, index) { // 元素首次渲染时的回调函数, 如果把updateItem设置为空,那么更新时则会兜底触发renderItem
@@ -31,9 +31,24 @@ const DEFAULTS = {
31
31
  export function Waterfall(optionsInput = {}) {
32
32
  $ = getEnv().$;
33
33
 
34
- this.options = Object.assign({}, DEFAULTS, optionsInput);
34
+ this.optionsInput = optionsInput
35
+
36
+ this.init();
37
+ }
38
+
39
+
40
+ Waterfall.prototype.init = function (optionsMain = null) {
41
+ if (optionsMain) {
42
+ this.options = Object.assign({}, DEFAULTS, optionsMain);
43
+ } else {
44
+ this.options = Object.assign({}, DEFAULTS, this.optionsInput);
45
+ }
46
+ const self = this;
35
47
  const options = this.options;
36
48
  const $container = $(options.container);
49
+ const $scrollDom = options.scrollDom ? $(options.scrollDom) : $container;
50
+
51
+
37
52
  // 标记是否有更新元素用的回调函数
38
53
  this.hasUpdateItem = options.updateItem && (options.updateItem.constructor === Function) ? true : false;
39
54
 
@@ -109,9 +124,14 @@ export function Waterfall(optionsInput = {}) {
109
124
  this.columnItems.push(this.createColumn(i));
110
125
  }
111
126
 
112
- this.renderIndex = 0; // 渲染索引(保留兼容性)
113
- this.activeNodes = new Map(); // 当前活跃节点(数据ID -> DOM)
127
+ this.$scrollDom = $scrollDom;
128
+
114
129
  this.nodePool = []; // DOM 节点池
130
+ this.activeNodes = new Map(); // 当前活跃节点(索引 -> DOM)
131
+ this.allReadyNodes = new Map(); // 所有节点(索引 -> DOM)
132
+ this.renderIndex = 0; // 渲染索引(保留兼容性)
133
+
134
+
115
135
 
116
136
  // 新方案:初始化数据ID映射
117
137
  this.dataIdMap = new Map(); // 数据ID -> 布局信息映射
@@ -128,23 +148,6 @@ export function Waterfall(optionsInput = {}) {
128
148
  });
129
149
  });
130
150
 
131
- this.init();
132
- }
133
-
134
-
135
- Waterfall.prototype.init = function () {
136
- const self = this;
137
- const options = this.options;
138
- const $container = $(options.container);
139
- const $scrollDom = options.scrollDom ? $(options.scrollDom) : $container;
140
-
141
- this.$scrollDom = $scrollDom;
142
-
143
- this.nodePool = []; // DOM 节点池
144
- this.activeNodes = new Map(); // 当前活跃节点(索引 -> DOM)
145
- this.allReadyNodes = new Map(); // 所有节点(索引 -> DOM)
146
- this.renderIndex = 0; // 渲染索引(保留兼容性)
147
-
148
151
  $container.html(`
149
152
  <div class="waterfall-list-scroll" style="">
150
153
  <div class="waterfall-list-viewport"></div>
@@ -803,6 +806,26 @@ Waterfall.prototype.setScrollHeight = function () {
803
806
  $container.find('.waterfall-list-scroll').css('height', h + 'px');
804
807
  }
805
808
 
809
+ // 销毁自己
810
+ Waterfall.prototype.destroy = function () {
811
+ const options = this.options;
812
+ const $container = $(options.container);
813
+ $container.html('');
814
+ this.activeNodes.clear();
815
+ this.allReadyNodes.clear();
816
+ this.dataIdMap.clear();
817
+ this.renderedDataIds.clear();
818
+ this.nodePool = [];
819
+ this.columnItems = [];
820
+ this.columns = 0;
821
+ this.columnWidth = 0;
822
+ this.renderIndex = 0;
823
+ this.scrollTop = 0;
824
+ this.isShowLoading = false;
825
+ this.$loadingNode = null;
826
+ this.$scrollDom = null;
827
+ }
828
+
806
829
  function createDefaultRow({ top, left }) {
807
830
  return {
808
831
  top,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tencent.jquery.pix.component",
3
- "version": "1.0.67",
3
+ "version": "1.0.69",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "files": [