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