@pixui-dev/pxw 0.1.16

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.
Files changed (128) hide show
  1. package/bin/pxw.js +217 -0
  2. package/bin/wpbuild.js +10 -0
  3. package/config/default.conf +21 -0
  4. package/config/devops.js +358 -0
  5. package/config/h5es.js +10 -0
  6. package/config/index.html +181 -0
  7. package/config/pfbs.js +207 -0
  8. package/config/testhelp.js +0 -0
  9. package/config/util.js +140 -0
  10. package/config/webpack.js +291 -0
  11. package/lib/assets/border.png +0 -0
  12. package/lib/assets/check.html +62 -0
  13. package/lib/assets/pixui.png +0 -0
  14. package/lib/assets/preact.js +4354 -0
  15. package/lib/assets/preact.png +0 -0
  16. package/lib/check/main.less +63 -0
  17. package/lib/check/main.tsx +41 -0
  18. package/lib/check/tool.js +3 -0
  19. package/lib/check/util.tsx +110 -0
  20. package/lib/grpc-web/dist/ChunkParser.js +117 -0
  21. package/lib/grpc-web/dist/ChunkParser.js.map +1 -0
  22. package/lib/grpc-web/dist/Code.js +58 -0
  23. package/lib/grpc-web/dist/Code.js.map +1 -0
  24. package/lib/grpc-web/dist/client.js +299 -0
  25. package/lib/grpc-web/dist/client.js.map +1 -0
  26. package/lib/grpc-web/dist/debug.js +16 -0
  27. package/lib/grpc-web/dist/debug.js.map +1 -0
  28. package/lib/grpc-web/dist/detach.js +7 -0
  29. package/lib/grpc-web/dist/detach.js.map +1 -0
  30. package/lib/grpc-web/dist/index.js +29 -0
  31. package/lib/grpc-web/dist/index.js.map +1 -0
  32. package/lib/grpc-web/dist/invoke.js +32 -0
  33. package/lib/grpc-web/dist/invoke.js.map +1 -0
  34. package/lib/grpc-web/dist/message.js +3 -0
  35. package/lib/grpc-web/dist/message.js.map +1 -0
  36. package/lib/grpc-web/dist/metadata.js +5 -0
  37. package/lib/grpc-web/dist/metadata.js.map +1 -0
  38. package/lib/grpc-web/dist/service.js +3 -0
  39. package/lib/grpc-web/dist/service.js.map +1 -0
  40. package/lib/grpc-web/dist/transports/Transport.js +15 -0
  41. package/lib/grpc-web/dist/transports/Transport.js.map +1 -0
  42. package/lib/grpc-web/dist/transports/http/fetch.js +117 -0
  43. package/lib/grpc-web/dist/transports/http/fetch.js.map +1 -0
  44. package/lib/grpc-web/dist/transports/http/http.js +15 -0
  45. package/lib/grpc-web/dist/transports/http/http.js.map +1 -0
  46. package/lib/grpc-web/dist/transports/http/xhr.js +136 -0
  47. package/lib/grpc-web/dist/transports/http/xhr.js.map +1 -0
  48. package/lib/grpc-web/dist/transports/http/xhrUtil.js +36 -0
  49. package/lib/grpc-web/dist/transports/http/xhrUtil.js.map +1 -0
  50. package/lib/grpc-web/dist/transports/websocket/websocket.js +95 -0
  51. package/lib/grpc-web/dist/transports/websocket/websocket.js.map +1 -0
  52. package/lib/grpc-web/dist/typings/ChunkParser.d.ts +17 -0
  53. package/lib/grpc-web/dist/typings/Code.d.ts +20 -0
  54. package/lib/grpc-web/dist/typings/client.d.ts +25 -0
  55. package/lib/grpc-web/dist/typings/debug.d.ts +1 -0
  56. package/lib/grpc-web/dist/typings/detach.d.ts +1 -0
  57. package/lib/grpc-web/dist/typings/index.d.ts +45 -0
  58. package/lib/grpc-web/dist/typings/invoke.d.ts +20 -0
  59. package/lib/grpc-web/dist/typings/message.d.ts +8 -0
  60. package/lib/grpc-web/dist/typings/metadata.d.ts +2 -0
  61. package/lib/grpc-web/dist/typings/service.d.ts +16 -0
  62. package/lib/grpc-web/dist/typings/transports/Transport.d.ts +22 -0
  63. package/lib/grpc-web/dist/typings/transports/http/fetch.d.ts +6 -0
  64. package/lib/grpc-web/dist/typings/transports/http/http.d.ts +5 -0
  65. package/lib/grpc-web/dist/typings/transports/http/xhr.d.ts +27 -0
  66. package/lib/grpc-web/dist/typings/transports/http/xhrUtil.d.ts +3 -0
  67. package/lib/grpc-web/dist/typings/transports/websocket/websocket.d.ts +2 -0
  68. package/lib/grpc-web/dist/typings/unary.d.ts +23 -0
  69. package/lib/grpc-web/dist/typings/util.d.ts +2 -0
  70. package/lib/grpc-web/dist/unary.js +44 -0
  71. package/lib/grpc-web/dist/unary.js.map +1 -0
  72. package/lib/grpc-web/dist/util.js +11 -0
  73. package/lib/grpc-web/dist/util.js.map +1 -0
  74. package/lib/grpcTransport/PixHttp2Transport.ts +107 -0
  75. package/lib/grpcTransport/PixLuaTransport.ts +82 -0
  76. package/lib/h5es-types/v1.9.2/h5es.d.ts +1698 -0
  77. package/lib/h5es-types/v3.5.0/h5es.d.ts +1788 -0
  78. package/lib/pi_component/tinyList/tinyList.js +483 -0
  79. package/lib/pi_component/tinyList/tinyList.tsx +517 -0
  80. package/lib/pika-svelte/compiler.js +29829 -0
  81. package/lib/pika-svelte/easing/index.js +158 -0
  82. package/lib/pika-svelte/index.js +72 -0
  83. package/lib/pika-svelte/internal/index.js +1926 -0
  84. package/lib/pika-svelte/motion/index.js +210 -0
  85. package/lib/pika-svelte/package.json +145 -0
  86. package/lib/pika-svelte/register.js +57 -0
  87. package/lib/pika-svelte/rollup.config.js +126 -0
  88. package/lib/pika-svelte/store/index.js +123 -0
  89. package/lib/pika-svelte/transition/index.js +185 -0
  90. package/lib/preact-router.js +395 -0
  91. package/lib/preact.js +4355 -0
  92. package/lib/preact.tq.js +4385 -0
  93. package/lib/react-window/src/FixedSizeGrid.js +172 -0
  94. package/lib/react-window/src/FixedSizeList.js +91 -0
  95. package/lib/react-window/src/VariableSizeGrid.js +329 -0
  96. package/lib/react-window/src/VariableSizeList.js +231 -0
  97. package/lib/react-window/src/__tests__/FixedSizeGrid.js +942 -0
  98. package/lib/react-window/src/__tests__/FixedSizeList.js +749 -0
  99. package/lib/react-window/src/__tests__/VariableSizeGrid.js +598 -0
  100. package/lib/react-window/src/__tests__/VariableSizeList.js +345 -0
  101. package/lib/react-window/src/__tests__/__snapshots__/FixedSizeGrid.js.snap +912 -0
  102. package/lib/react-window/src/__tests__/__snapshots__/FixedSizeList.js.snap +568 -0
  103. package/lib/react-window/src/__tests__/__snapshots__/VariableSizeGrid.js.snap +542 -0
  104. package/lib/react-window/src/__tests__/__snapshots__/VariableSizeList.js.snap +331 -0
  105. package/lib/react-window/src/__tests__/areEqual.js +28 -0
  106. package/lib/react-window/src/__tests__/shouldComponentUpdate.js +32 -0
  107. package/lib/react-window/src/areEqual.js +13 -0
  108. package/lib/react-window/src/createGridComponent.js +657 -0
  109. package/lib/react-window/src/createListComponent.js +574 -0
  110. package/lib/react-window/src/domHelpers.js +69 -0
  111. package/lib/react-window/src/index.js +9 -0
  112. package/lib/react-window/src/shallowDiffers.js +17 -0
  113. package/lib/react-window/src/shouldComponentUpdate.js +11 -0
  114. package/lib/react-window/src/test.js.flow +382 -0
  115. package/lib/react-window/src/timer.js +36 -0
  116. package/lib/svelte-tab/Tab.svelte +31 -0
  117. package/lib/svelte-tab/TabList.svelte +10 -0
  118. package/lib/svelte-tab/TabPanel.svelte +13 -0
  119. package/lib/svelte-tab/Tabs.svelte +68 -0
  120. package/lib/svelte-tab/tabs.js +4 -0
  121. package/lib/types/css.d.ts +7476 -0
  122. package/lib/types/dom.ts +17 -0
  123. package/lib/types/ext.d.ts +81 -0
  124. package/lib/types/internal.d.ts +94 -0
  125. package/lib/types/jsx.d.ts +309 -0
  126. package/lib/types/preact.d.ts +340 -0
  127. package/package.json +111 -0
  128. package/tsconfig.json +30 -0
@@ -0,0 +1,517 @@
1
+ export const Direction = {
2
+ Horizontal: 0,
3
+ Vertical: 1,
4
+ };
5
+
6
+ Object.freeze(Direction);
7
+
8
+ export class TinyList {
9
+ private startIndex = 0;
10
+ private endIndex = -1;
11
+ private startBoundary = 0;
12
+ private endBoundary = 0;
13
+ private containerWidth = 0;
14
+ private viewHeight = 0;
15
+ private viewWidth = 0;
16
+ private containerHeight = 0;
17
+ private scorllDirection = Direction.Vertical;
18
+
19
+ private itemSize = 0;
20
+ private defaultItemSize = 200;
21
+
22
+ private viewDiv;
23
+ private contentDiv;
24
+
25
+ private itemCount = 0;
26
+ private itemPool: any[] = [];
27
+ private itemMap = {};
28
+ private itemSizeList: any[] = [];
29
+ private MOVE_DELTA = 5;
30
+ private curScrollOffset = 0;
31
+ private fillItemFunc;
32
+ private onStartFunc;
33
+ private onEndFunc;
34
+ private CalculateItemSizeFunc;
35
+
36
+ private cacheNumber = 0;//多缓存几个数量
37
+
38
+ //root:该瀑布流组件根节点
39
+ //count:当前列表的数量
40
+ //viewSize:瀑布流组件viewSize,高或宽超出部分不显示
41
+ //direction:方向,暂时仅支持垂直
42
+ //calculatedSize:单元格固定尺寸,可设置为一个计算单元格高度的函数。
43
+ //cacheNum:滑动过快的话,可稍微增加几个缓存,设置缓存数量。
44
+ //fillFunc:填充具体对应的Item函数委托
45
+ public CreateList = (root, count, viewSize, direction, calculatedSize, cacheNum, fillFunc)=> {
46
+ if(root != undefined) {
47
+ this.itemCount = count;
48
+ this.scorllDirection = direction;
49
+ this.cacheNumber = cacheNum;
50
+ if (typeof calculatedSize == 'function') {
51
+ // console.log('--------------- this.itemSize is Funtion -------------------')
52
+ this.CalculateItemSizeFunc = calculatedSize;
53
+ }
54
+ else {
55
+ // console.log('--------------- this.itemSize is size Num -------------------')
56
+ this.itemSize = calculatedSize;
57
+ }
58
+ this.viewDiv = document.createElement('div');
59
+ this.viewDiv.style.position = 'relative';
60
+ this.viewDiv.style.overflow = 'scroll';
61
+ this.viewDiv.style.willChange = 'transform';
62
+ this.viewDiv.style.left = '0px';
63
+ this.viewDiv.style.top = '0px';
64
+
65
+ this.viewDiv.addEventListener('scroll', this.onScroll);
66
+ root.appendChild(this.viewDiv);
67
+ //创建一个contener
68
+ this.contentDiv = document.createElement('div');
69
+
70
+ if(this.scorllDirection == Direction.Horizontal) {
71
+ this.viewWidth = viewSize ;
72
+ this.viewDiv.style.flexDirection = 'row';
73
+ // this.viewDiv.style.height = `100%`;
74
+ this.viewDiv.style.height = '400px';
75
+ this.viewDiv.style.width = `${viewSize}px`;
76
+ this.viewWidth = viewSize ;
77
+ this.contentDiv.style.height = '100%';
78
+ }
79
+ else {
80
+ this.viewDiv.style.flexDirection = 'column';
81
+ this.viewDiv.style.height = `${viewSize}px`;
82
+ this.viewDiv.style.width = '100%';
83
+ this.viewHeight = viewSize ;
84
+ this.contentDiv.style.width = '100%';
85
+ }
86
+ this.viewDiv.appendChild(this.contentDiv);
87
+ this.InitItemsSize(0, this.itemCount);
88
+ this.fillItemFunc = fillFunc;
89
+ this.itemMap = {};
90
+ this.fill();
91
+ }
92
+ else
93
+ console.log('---------- 未能找到瀑布流组件根节点!!!! ------------');
94
+ return this.viewDiv;
95
+ };
96
+
97
+ private InitItemsSize = (begin, end)=> {
98
+ for(let i = begin; i < end; i++) {
99
+ this.itemSizeList[i] = -1;
100
+ }
101
+ };
102
+
103
+ private GetItemSize = (index)=> {
104
+ let curSize = 0;
105
+ if(this.CalculateItemSizeFunc != undefined) {
106
+ if(this.itemSizeList[index] != undefined && this.itemSizeList[index] != -1) {
107
+ curSize = this.itemSizeList[index];
108
+ }
109
+ else {
110
+ curSize = this.CalculateItemSizeFunc(index);
111
+ this.itemSizeList[index] = curSize;
112
+ }
113
+ }
114
+ else
115
+ curSize = this.itemSize;
116
+ return curSize;
117
+ };
118
+
119
+ public SetOnStartFunc = (onStart)=> {
120
+ this.onStartFunc = onStart;
121
+ };
122
+
123
+ public SetOnEndFunc = (onEnd)=> {
124
+ this.onEndFunc = onEnd;
125
+ };
126
+
127
+ private onScroll = ( event ) => {
128
+ // const { clientHeight, scrollHeight, scrollTop } = event.currentTarget;
129
+ const {scrollLeft, scrollTop } = event.currentTarget;
130
+ // console.log('================== scrollLeft: ', scrollLeft);
131
+ // console.log('================== scrollTop ', scrollTop);
132
+ if(this.scorllDirection == Direction.Horizontal) {
133
+ if(scrollLeft == 0 ) {
134
+ if(this.onStartFunc != undefined) {
135
+ this.onStartFunc();
136
+ this.Leftward();
137
+ return;
138
+ }
139
+ }
140
+ else if(scrollLeft > 0 && (scrollLeft + this.viewWidth) >= this.endBoundary ) {
141
+ if(this.onEndFunc != undefined) {
142
+ // console.log("----------this.onEndFunc this.viewDiv scrollLeft:", scrollLeft, "------------");
143
+ // console.log("----------this.onEndFunc this.endBoundary:", this.endBoundary, "------------");
144
+
145
+ // console.log("---------- this.onEndFunc this.viewDiv top:", this.viewDiv.scrollTop, "------------");
146
+ this.onEndFunc();
147
+ // Rightward();
148
+ return;
149
+ }
150
+ }
151
+ const distance = scrollLeft - this.curScrollOffset;
152
+ this.curScrollOffset = scrollLeft;
153
+ if(distance >= this.MOVE_DELTA) {
154
+ this.Leftward();
155
+ }
156
+ else if(distance < -this.MOVE_DELTA) {
157
+ this.Rightward();
158
+ }
159
+ }
160
+ else {
161
+ if(scrollTop == 0 ) {
162
+ if(this.onStartFunc != undefined) {
163
+ this.onStartFunc();
164
+ this.Forward();
165
+ return;
166
+ }
167
+ }
168
+ else if(scrollTop > 0 && (scrollTop + this.viewHeight) >= this.endBoundary) {
169
+ if(this.onEndFunc != undefined) {
170
+ this.onEndFunc();
171
+ return;
172
+ }
173
+ }
174
+ const distance = scrollTop - this.curScrollOffset;
175
+ this.curScrollOffset = scrollTop;
176
+ if(distance >= this.MOVE_DELTA) {
177
+ this.Forward();
178
+ }
179
+ else if(distance < -this.MOVE_DELTA) {
180
+ this.BackWard();
181
+ }
182
+ }
183
+ };
184
+
185
+ public AppendList = (count)=> {
186
+ const curIndex = this.itemCount;
187
+ this.itemCount = this.itemCount + count;
188
+ this.InitItemsSize( curIndex, this.itemCount);
189
+ if(this.scorllDirection == Direction.Horizontal)
190
+ this.Leftward();
191
+ else
192
+ this.Forward();
193
+ };
194
+
195
+ private resetContentPosision = ()=> {
196
+ // this.viewDiv.scrollTop = 0;
197
+ };
198
+
199
+ public Refresh = (count)=> {
200
+ this.RecycleAll();
201
+ this.itemCount = count;
202
+ this.itemSizeList = [];
203
+ this.InitItemsSize(0, this.itemCount);
204
+ this.curScrollOffset = 0;
205
+ this.viewDiv.scrollTop = 0;
206
+ this.fill();
207
+ };
208
+
209
+ private fill = () => {
210
+ // console.log("---------- fillItem ------------")
211
+ this.startIndex = 0;
212
+ this.endIndex = -1;
213
+ this.startBoundary = 0;
214
+ this.endBoundary = 0;
215
+ this.containerHeight = 0;
216
+ this.containerWidth = 0;
217
+ this.curScrollOffset = 0;
218
+
219
+ if(this.scorllDirection == Direction.Horizontal)
220
+ this.Leftward();
221
+ else
222
+ this.Forward();
223
+
224
+ // console.log("---------- this.viewDiv left:", this.viewDiv.scrollLeft, "------------");
225
+ // console.log("---------- this.viewDiv top:", this.viewDiv.scrollTop, "------------");
226
+ };
227
+
228
+ private CreateItem = ( index ) => {
229
+ let item;
230
+ // console.log('CreateItem pool size:', this.itemPool.length)
231
+ //console.log('----------@@@@@ CreateItem:', index)
232
+ if(this.itemPool.length > 0) {
233
+ // console.log("---------- useItemPool ------------")
234
+ item = this.itemPool.pop();//this.itemPool[0];
235
+ item.style.display = 'flex';
236
+ item.id = 'item_' + index;
237
+ this.fillItemFunc(item, index);
238
+ }
239
+ else {
240
+ // console.log("---------- this.itemPool is null!!! ------------")
241
+ if(this.fillItemFunc != undefined) {
242
+ item = document.createElement('div');
243
+ item.id = 'item_' + index;
244
+ this.fillItemFunc(item, index);
245
+ this.contentDiv.appendChild(item);
246
+ }
247
+ const curSize = this.GetItemSize(index);
248
+ if(this.scorllDirection == Direction.Horizontal) {
249
+ item.style.width = `${curSize}`;
250
+ }
251
+ else {
252
+ // console.log("---------- curSize:",curSize," ------------")
253
+ item.style.height = `${curSize}`;
254
+
255
+ }
256
+ }
257
+ return item;
258
+ };
259
+
260
+ private Forward = () => {
261
+ // console.log("---------- Forward ------------")
262
+ // console.log("---------- this.endBoundary:",this.endBoundary, this.curScrollOffset, this.endIndex, " ------------")
263
+ // console.log("---------- this.itemCount:",this.itemCount, " ------------")
264
+ // console.log("---------- boundary:",this.curScrollOffset + this.viewHeight + this.cacheNumber*this.defaultItemSize , " ------------")
265
+ while ((this.endIndex < this.itemCount - 1) && this.endBoundary < (this.curScrollOffset + this.viewHeight + this.cacheNumber * this.defaultItemSize ))//this.itemSize
266
+ {
267
+ this.endIndex++;
268
+ let item = this.CreateItem(this.endIndex);
269
+ this.itemMap[`${this.endIndex}`] = item;
270
+ this.SetItemPosition(item, this.endBoundary);
271
+ this.RefreshEndBundary();
272
+ this.CalculateContentSize();
273
+ }
274
+ this.RecycleBegin();
275
+ };
276
+
277
+ private BackWard = () => {
278
+ // console.log("---------- BackWard ------------")
279
+ // console.log("---------- this.startBoundary:",this.startBoundary, this.curScrollOffset, this.startIndex, " ------------")
280
+ while (this.startIndex > 0 && this.curScrollOffset <= this.startBoundary) {
281
+ this.startIndex--;
282
+ let item = this.CreateItem(this.startIndex);
283
+ this.itemMap[`${this.startIndex}`] = item;
284
+ let height = 0;
285
+ height = this.GetItemSize(this.startIndex);
286
+ this.SetItemPosition(item, this.startBoundary - height);
287
+ this.RefreshBeginBundary();
288
+ }
289
+ this.RecycleEnd();
290
+ };
291
+
292
+ private Leftward = () => {
293
+ // console.log("---------- Leftward ------------")
294
+ // console.log("---------- this.endBoundary:",this.endBoundary, this.curScrollOffset, this.endIndex, " ------------")
295
+ while ((this.endIndex < this.itemCount - 1) && this.endBoundary < (this.curScrollOffset + this.viewWidth + this.cacheNumber * this.defaultItemSize ))//
296
+ {
297
+ this.endIndex++;
298
+ // console.log("---------- this.endIndex:", this.endIndex," ------------")
299
+ let item = this.CreateItem(this.endIndex);
300
+ this.itemMap[`${this.endIndex}`] = item;
301
+ this.SetItemPosition(item, this.endBoundary);
302
+ this.RefreshEndBundary();
303
+ this.CalculateContentSize();
304
+ }
305
+ this.RecycleBegin();
306
+ };
307
+
308
+ private Rightward = () => {
309
+ // console.log("---------- Rightward ------------")
310
+ // console.log("---------- this.startBoundary:",this.startBoundary, this.curScrollOffset, this.startIndex, " ------------")
311
+ while (this.startIndex > 0 && this.curScrollOffset <= this.startBoundary) {
312
+ this.startIndex--;
313
+ let item = this.CreateItem(this.startIndex);
314
+ this.itemMap[`${this.startIndex}`] = item;
315
+ let width = 0;
316
+ width = this.GetItemSize(this.startIndex);
317
+ this.SetItemPosition(item, this.startBoundary - width);
318
+ this.RefreshBeginBundary();
319
+ }
320
+ this.RecycleEnd();
321
+ };
322
+
323
+ private SetItemPosition = (item, itemPos) => {
324
+ // console.log("---------- SetItemPosition itemPos:",itemPos," ------------")
325
+ if(this.scorllDirection == Direction.Horizontal) {
326
+ // console.log("---------- this.scorllDirection == Direction.Horizontal ------------")
327
+ item.style.left = `${itemPos}`;
328
+ }
329
+ else
330
+ item.style.top = `${itemPos}`;
331
+ };
332
+
333
+ private RefreshEndBundary = () => {
334
+ // console.log("----------@@@ this.endIndex :",this.endIndex," ------------")
335
+ // console.log("----------@@@ RefreshEndBundary:",this.endBoundary," ------------")
336
+ let item = this.itemMap[`${this.endIndex}`];
337
+ if(this.scorllDirection == Direction.Horizontal) {
338
+ let curLeft = parseInt(item.style.left);
339
+ let width = 0;
340
+ width = this.GetItemSize(this.endIndex);
341
+ this.endBoundary = curLeft + width;
342
+ }
343
+ else {
344
+ let curTop = parseInt(item.style.top);
345
+ let height = 0;
346
+ height = this.GetItemSize(this.endIndex);
347
+ this.endBoundary = curTop + height;
348
+ }
349
+ };
350
+
351
+ private RefreshBeginBundary = () => {
352
+ if(this.CalculateItemSizeFunc != undefined) {
353
+ this.startBoundary = this.GetItemsRange(0, this.startIndex - 1) ;
354
+ }
355
+ else
356
+ this.startBoundary = this.itemSize * this.startIndex;
357
+ };
358
+
359
+ private CalculateContentSize = () => {
360
+ if(this.scorllDirection == Direction.Horizontal) {
361
+ this.containerWidth = this.endBoundary ;
362
+ this.contentDiv.style.width = `${this.containerWidth}`;
363
+ }
364
+ else {
365
+ this.containerHeight = this.endBoundary ;
366
+ this.contentDiv.style.height = `${this.containerHeight}`;
367
+ }
368
+ // console.log("----------CalculateContentSize height:",height,"------------")
369
+ };
370
+
371
+ private IsItemUpOfViewport = (index, item) => {
372
+ let itemOffset = 0;
373
+ if(this.scorllDirection == Direction.Horizontal)
374
+ itemOffset = parseInt(item.style.left);
375
+ else
376
+ itemOffset = parseInt(item.style.top);
377
+
378
+ let curSize = 0;
379
+ if(this.CalculateItemSizeFunc != undefined) {
380
+ curSize = this.CalculateItemSizeFunc(index);
381
+ }
382
+ else
383
+ curSize = this.itemSize;
384
+ if((itemOffset + curSize) < this.curScrollOffset) {
385
+ // console.log("----------IsItemUpOfViewport true------------")
386
+ return true;
387
+ }
388
+ else {
389
+ // console.log("----------IsItemUpOfViewport false------------")
390
+ return false;
391
+ }
392
+ };
393
+
394
+ private IsItemBottomOfViewport = (item) => {
395
+ let itemOffset = 0;
396
+ if(this.scorllDirection == Direction.Horizontal) {
397
+ itemOffset = parseInt(item.style.left);
398
+ if(itemOffset > this.curScrollOffset + this.viewWidth ) {
399
+ return true;
400
+ }
401
+ else {
402
+ // console.log("----------IsItemBottomOfViewport false------------")
403
+ return false;
404
+ }
405
+ }
406
+ else {
407
+ itemOffset = parseInt(item.style.top);
408
+ if(itemOffset > this.curScrollOffset + this.viewHeight ) {
409
+ return true;
410
+ }
411
+ else {
412
+ // console.log("----------IsItemBottomOfViewport false------------")
413
+ return false;
414
+ }
415
+ }
416
+ };
417
+
418
+ private RecycleBegin = () => {
419
+ // if(IsInRange())
420
+ // {
421
+ // return;
422
+ // }
423
+ let i = this.startIndex;
424
+ while(i <= this.endIndex) {
425
+ let item = this.itemMap[`${i}`];
426
+ if(item != undefined ) {
427
+ if(this.IsItemUpOfViewport(i, item)) {
428
+ if(this.scorllDirection == Direction.Horizontal)
429
+ item.style.left = `${-(this.viewWidth)}`;
430
+ else
431
+ item.style.top = `${-(this.viewHeight)}`;
432
+ // console.log('push item');
433
+ item.style.display = 'none';
434
+ this.itemPool.push(item);
435
+ this.startIndex++;
436
+ }
437
+ }
438
+ else {
439
+ break;
440
+ }
441
+ i++;
442
+ }
443
+ this.RefreshBeginBundary();
444
+ // console.log("----------RecycleBegin startIndex:",this.startIndex,"------------")
445
+ };
446
+
447
+ private RecycleEnd = () => {
448
+
449
+ // if(IsInRange())
450
+ // {
451
+ // return;
452
+ // }
453
+
454
+ let i = this.endIndex;
455
+ while(i >= this.startIndex) {
456
+ let item = this.itemMap[`${i}`];
457
+ if(item != undefined ) {
458
+ if(this.IsItemBottomOfViewport(item)) {
459
+ if(this.scorllDirection == Direction.Horizontal)
460
+ item.style.left = `${-(this.viewWidth)}`;
461
+ else
462
+ item.style.top = `${-(this.viewHeight)}`;
463
+ item.style.display = 'none';
464
+ this.itemPool.push(item);
465
+ this.endIndex--;
466
+ }
467
+ }
468
+ else {
469
+ break;
470
+ }
471
+ i--;
472
+ }
473
+ this.RefreshEndBundary();
474
+ };
475
+
476
+ private IsInRange = () => {
477
+ let isInRange = true;
478
+ const range = this.GetItemsRange(this.startIndex, this.endIndex - 1);
479
+ if(this.scorllDirection == Direction.Horizontal) {
480
+ if(range < this.viewWidth)
481
+ isInRange = false;
482
+ }
483
+ else {
484
+ if(range < this.viewHeight)
485
+ isInRange = false;
486
+ }
487
+ return isInRange;
488
+ };
489
+
490
+ private GetItemsRange = (start, end) => {
491
+ let range = 0;
492
+ for(let begin = start; begin <= end; begin++) {
493
+ if(this.itemMap[`${begin}`] != undefined) {
494
+
495
+ range = range + this.GetItemSize(begin);
496
+ }
497
+ }
498
+ return range;
499
+ };
500
+
501
+ private RecycleAll = () => {
502
+ // console.log("----------------- RecycleAll ---------------- ")
503
+ for(let i = this.startIndex; i < this.endIndex; i++) {
504
+ let item = this.itemMap[`${i}`];
505
+ if(item != undefined ) {
506
+ if(this.scorllDirection == Direction.Horizontal)
507
+ item.style.left = `${-(this.viewWidth)}`;
508
+ else
509
+ item.style.top = `${-(this.viewHeight)}`;
510
+ // console.log('push item');
511
+ item.style.display = 'none';
512
+ this.itemPool.push(item);
513
+ }
514
+ }
515
+ };
516
+
517
+ }