@tarojs/components-advanced 3.6.10 → 3.6.11-alpha.4
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/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/virtual-list/index.d.ts +49 -30
- package/dist/components/virtual-list/index.js.map +1 -1
- package/dist/components/virtual-list/list-set.d.ts +4 -0
- package/dist/components/virtual-list/list-set.js +24 -59
- package/dist/components/virtual-list/list-set.js.map +1 -1
- package/dist/components/virtual-list/preset.d.ts +23 -8
- package/dist/components/virtual-list/preset.js +116 -60
- package/dist/components/virtual-list/preset.js.map +1 -1
- package/dist/components/virtual-list/react/index.d.ts +1 -1
- package/dist/components/virtual-list/react/index.js +8 -16
- package/dist/components/virtual-list/react/index.js.map +1 -1
- package/dist/components/virtual-list/react/list.d.ts +5 -4
- package/dist/components/virtual-list/react/list.js +138 -124
- package/dist/components/virtual-list/react/list.js.map +1 -1
- package/dist/components/virtual-list/react/validate.d.ts +1 -1
- package/dist/components/virtual-list/react/validate.js +8 -14
- package/dist/components/virtual-list/react/validate.js.map +1 -1
- package/dist/components/virtual-list/react/wrapper.d.ts +3 -0
- package/dist/components/virtual-list/react/wrapper.js +58 -0
- package/dist/components/virtual-list/react/wrapper.js.map +1 -0
- package/dist/components/virtual-list/utils.d.ts +1 -4
- package/dist/components/virtual-list/utils.js +1 -28
- package/dist/components/virtual-list/utils.js.map +1 -1
- package/dist/components/virtual-list/vue/list.d.ts +406 -50
- package/dist/components/virtual-list/vue/list.js +198 -169
- package/dist/components/virtual-list/vue/list.js.map +1 -1
- package/dist/components/virtual-waterfall/constants.d.ts +2 -0
- package/dist/components/virtual-waterfall/constants.js +4 -0
- package/dist/components/virtual-waterfall/constants.js.map +1 -0
- package/dist/components/virtual-waterfall/index.d.ts +249 -0
- package/dist/components/virtual-waterfall/index.js +6 -0
- package/dist/components/virtual-waterfall/index.js.map +1 -0
- package/dist/components/virtual-waterfall/list-map.d.ts +50 -0
- package/dist/components/virtual-waterfall/list-map.js +280 -0
- package/dist/components/virtual-waterfall/list-map.js.map +1 -0
- package/dist/components/virtual-waterfall/preset.d.ts +60 -0
- package/dist/components/virtual-waterfall/preset.js +170 -0
- package/dist/components/virtual-waterfall/preset.js.map +1 -0
- package/dist/components/virtual-waterfall/react/index.d.ts +4 -0
- package/dist/components/virtual-waterfall/react/index.js +26 -0
- package/dist/components/virtual-waterfall/react/index.js.map +1 -0
- package/dist/components/virtual-waterfall/react/waterfall.d.ts +42 -0
- package/dist/components/virtual-waterfall/react/waterfall.js +316 -0
- package/dist/components/virtual-waterfall/react/waterfall.js.map +1 -0
- package/dist/components/virtual-waterfall/react/wrapper.d.ts +3 -0
- package/dist/components/virtual-waterfall/react/wrapper.js +50 -0
- package/dist/components/virtual-waterfall/react/wrapper.js.map +1 -0
- package/dist/components/virtual-waterfall/vue/index.d.ts +17 -0
- package/dist/components/virtual-waterfall/vue/index.js +12 -0
- package/dist/components/virtual-waterfall/vue/index.js.map +1 -0
- package/dist/components/virtual-waterfall/vue/waterfall.d.ts +443 -0
- package/dist/components/virtual-waterfall/vue/waterfall.js +410 -0
- package/dist/components/virtual-waterfall/vue/waterfall.js.map +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/convert.d.ts +2 -2
- package/dist/utils/convert.js.map +1 -1
- package/dist/utils/dom.d.ts +7 -0
- package/dist/utils/dom.js +45 -0
- package/dist/utils/dom.js.map +1 -0
- package/dist/utils/helper.d.ts +10 -0
- package/dist/utils/helper.js +51 -0
- package/dist/utils/helper.js.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/lodash.d.ts +3 -1
- package/dist/utils/lodash.js +30 -1
- package/dist/utils/lodash.js.map +1 -1
- package/dist/utils/vue-render.d.ts +4 -0
- package/dist/{components/virtual-list/vue/render.js → utils/vue-render.js} +2 -2
- package/dist/utils/vue-render.js.map +1 -0
- package/package.json +8 -6
- package/dist/components/virtual-list/vue/render.d.ts +0 -4
- package/dist/components/virtual-list/vue/render.js.map +0 -1
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { isWebPlatform } from '@tarojs/shared';
|
|
2
2
|
import memoizeOne from 'memoize-one';
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import { defineComponent } from 'vue';
|
|
4
|
+
import '../../../utils/index.js';
|
|
5
|
+
import render from '../../../utils/vue-render.js';
|
|
6
6
|
import { IS_SCROLLING_DEBOUNCE_INTERVAL } from '../constants.js';
|
|
7
7
|
import { getRTLOffsetType } from '../dom-helpers.js';
|
|
8
8
|
import Preset from '../preset.js';
|
|
9
|
-
import { getScrollViewContextNode,
|
|
10
|
-
import
|
|
9
|
+
import { getScrollViewContextNode, getRectSizeSync } from '../../../utils/dom.js';
|
|
10
|
+
import { cancelTimeout, requestTimeout } from '../../../utils/timer.js';
|
|
11
|
+
import { defaultItemKey } from '../../../utils/helper.js';
|
|
12
|
+
import { convertNumber2PX } from '../../../utils/convert.js';
|
|
13
|
+
import { omit } from '../../../utils/lodash.js';
|
|
11
14
|
|
|
12
15
|
const isWeb = isWebPlatform();
|
|
13
|
-
var List = {
|
|
16
|
+
var List = defineComponent({
|
|
14
17
|
props: {
|
|
18
|
+
id: String,
|
|
15
19
|
height: {
|
|
16
20
|
type: [String, Number],
|
|
17
21
|
required: true
|
|
@@ -20,6 +24,9 @@ var List = {
|
|
|
20
24
|
type: [String, Number],
|
|
21
25
|
required: true
|
|
22
26
|
},
|
|
27
|
+
item: {
|
|
28
|
+
required: true
|
|
29
|
+
},
|
|
23
30
|
itemCount: {
|
|
24
31
|
type: Number,
|
|
25
32
|
required: true
|
|
@@ -28,6 +35,7 @@ var List = {
|
|
|
28
35
|
type: Array,
|
|
29
36
|
required: true
|
|
30
37
|
},
|
|
38
|
+
itemKey: Function,
|
|
31
39
|
itemSize: {
|
|
32
40
|
type: [Number, Function],
|
|
33
41
|
required: true
|
|
@@ -40,14 +48,6 @@ var List = {
|
|
|
40
48
|
type: String,
|
|
41
49
|
default: 'absolute'
|
|
42
50
|
},
|
|
43
|
-
initialScrollOffset: {
|
|
44
|
-
type: Number,
|
|
45
|
-
default: 0
|
|
46
|
-
},
|
|
47
|
-
innerElementType: {
|
|
48
|
-
type: String,
|
|
49
|
-
default: isWeb ? 'taro-view-core' : 'view'
|
|
50
|
-
},
|
|
51
51
|
direction: {
|
|
52
52
|
type: String,
|
|
53
53
|
default: 'ltr'
|
|
@@ -56,6 +56,10 @@ var List = {
|
|
|
56
56
|
type: String,
|
|
57
57
|
default: 'vertical'
|
|
58
58
|
},
|
|
59
|
+
initialScrollOffset: {
|
|
60
|
+
type: Number,
|
|
61
|
+
default: 0
|
|
62
|
+
},
|
|
59
63
|
overscanCount: {
|
|
60
64
|
type: Number,
|
|
61
65
|
default: 1
|
|
@@ -67,39 +71,41 @@ var List = {
|
|
|
67
71
|
type: Boolean,
|
|
68
72
|
default: false
|
|
69
73
|
},
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
enhanced: {
|
|
75
|
+
type: Boolean,
|
|
76
|
+
default: false
|
|
77
|
+
},
|
|
78
|
+
shouldResetStyleCacheOnItemSizeChange: {
|
|
79
|
+
type: Boolean,
|
|
80
|
+
default: true
|
|
72
81
|
},
|
|
73
|
-
|
|
74
|
-
itemTagName: {
|
|
82
|
+
outerElementType: {
|
|
75
83
|
type: String,
|
|
76
|
-
default: isWeb ? 'taro-view-core' : 'view'
|
|
84
|
+
default: isWeb ? 'taro-scroll-view-core' : 'scroll-view'
|
|
77
85
|
},
|
|
78
|
-
|
|
86
|
+
innerElementType: {
|
|
79
87
|
type: String,
|
|
80
88
|
default: isWeb ? 'taro-view-core' : 'view'
|
|
81
89
|
},
|
|
82
|
-
|
|
90
|
+
itemElementType: {
|
|
83
91
|
type: String,
|
|
84
|
-
default: isWeb ? 'taro-
|
|
92
|
+
default: isWeb ? 'taro-view-core' : 'view'
|
|
85
93
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
94
|
+
outerTagName: String,
|
|
95
|
+
innerTagName: String,
|
|
96
|
+
itemTagName: String,
|
|
89
97
|
outerRef: String,
|
|
90
|
-
|
|
98
|
+
innerRef: String,
|
|
91
99
|
onScrollNative: Function,
|
|
92
|
-
|
|
93
|
-
type: Boolean,
|
|
94
|
-
default: true
|
|
95
|
-
},
|
|
100
|
+
onItemsRendered: Function,
|
|
96
101
|
},
|
|
97
102
|
data() {
|
|
98
103
|
const preset = new Preset(this.$props, this.refresh);
|
|
104
|
+
const id = this.$props.id || preset.id;
|
|
105
|
+
preset.updateWrapper(id);
|
|
99
106
|
return {
|
|
100
107
|
itemList: preset.itemList,
|
|
101
108
|
preset,
|
|
102
|
-
id: this.$props.id || preset.id,
|
|
103
109
|
instance: this,
|
|
104
110
|
isScrolling: false,
|
|
105
111
|
scrollDirection: 'forward',
|
|
@@ -115,8 +121,7 @@ var List = {
|
|
|
115
121
|
refresh() {
|
|
116
122
|
this.refreshCount = this.refreshCount + 1;
|
|
117
123
|
},
|
|
118
|
-
scrollTo(scrollOffset) {
|
|
119
|
-
const { enhanced } = this.$props;
|
|
124
|
+
scrollTo(scrollOffset = 0, enhanced = this.preset.enhanced) {
|
|
120
125
|
scrollOffset = Math.max(0, scrollOffset);
|
|
121
126
|
if (this.scrollOffset === scrollOffset)
|
|
122
127
|
return;
|
|
@@ -124,7 +129,7 @@ var List = {
|
|
|
124
129
|
const isHorizontal = this.preset.isHorizontal;
|
|
125
130
|
const option = {
|
|
126
131
|
animated: true,
|
|
127
|
-
duration:
|
|
132
|
+
duration: 300,
|
|
128
133
|
};
|
|
129
134
|
if (isHorizontal) {
|
|
130
135
|
option.left = scrollOffset;
|
|
@@ -132,25 +137,25 @@ var List = {
|
|
|
132
137
|
else {
|
|
133
138
|
option.top = scrollOffset;
|
|
134
139
|
}
|
|
135
|
-
return getScrollViewContextNode(`#${this
|
|
140
|
+
return getScrollViewContextNode(`#${this.preset.id}`).then((node) => node.scrollTo(option));
|
|
136
141
|
}
|
|
137
142
|
this.scrollDirection = this.scrollOffset < scrollOffset ? 'forward' : 'backward';
|
|
138
143
|
this.scrollOffset = scrollOffset;
|
|
139
144
|
this.scrollUpdateWasRequested = true;
|
|
140
145
|
this.$nextTick(this._resetIsScrollingDebounced);
|
|
141
146
|
},
|
|
142
|
-
scrollToItem(index, align = 'auto') {
|
|
147
|
+
scrollToItem(index, align = 'auto', enhanced = this.preset.enhanced) {
|
|
143
148
|
const { itemCount } = this.$props;
|
|
144
149
|
const { scrollOffset } = this.$data;
|
|
145
150
|
index = Math.max(0, Math.min(index, itemCount - 1));
|
|
146
|
-
this.scrollTo(this.itemList.getOffsetForIndexAndAlignment(
|
|
151
|
+
this.scrollTo(this.itemList.getOffsetForIndexAndAlignment(index, align, scrollOffset), enhanced);
|
|
147
152
|
},
|
|
148
|
-
_callOnItemsRendered: memoizeOne(function (overscanStartIndex, overscanStopIndex,
|
|
153
|
+
_callOnItemsRendered: memoizeOne(function (overscanStartIndex, overscanStopIndex, startIndex, stopIndex) {
|
|
149
154
|
return this.$props.onItemsRendered({
|
|
150
155
|
overscanStartIndex,
|
|
151
156
|
overscanStopIndex,
|
|
152
|
-
|
|
153
|
-
|
|
157
|
+
startIndex,
|
|
158
|
+
stopIndex
|
|
154
159
|
});
|
|
155
160
|
}),
|
|
156
161
|
_callOnScroll: memoizeOne(function (scrollDirection, scrollOffset, scrollUpdateWasRequested, detail) {
|
|
@@ -163,52 +168,49 @@ var List = {
|
|
|
163
168
|
}),
|
|
164
169
|
_callPropsCallbacks() {
|
|
165
170
|
if (typeof this.$props.onItemsRendered === 'function') {
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
this._callOnItemsRendered(overscanStartIndex, overscanStopIndex, visibleStartIndex, visibleStopIndex);
|
|
171
|
+
if (this.$props.itemCount > 0) {
|
|
172
|
+
const [overscanStartIndex, overscanStopIndex, startIndex, stopIndex] = this._getRangeToRender();
|
|
173
|
+
this._callOnItemsRendered(overscanStartIndex, overscanStopIndex, startIndex, stopIndex);
|
|
170
174
|
}
|
|
171
175
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
this.
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
if (typeof this.$props.onScroll === 'function') {
|
|
177
|
+
this._callOnScroll(this.scrollDirection, this.scrollOffset, this.scrollUpdateWasRequested, this.preset.field);
|
|
178
|
+
}
|
|
179
|
+
if (this.itemList.isUnlimitedMode) {
|
|
180
|
+
setTimeout(() => {
|
|
181
|
+
const [startIndex, stopIndex] = this._getRangeToRender();
|
|
182
|
+
const isHorizontal = this.preset.isHorizontal;
|
|
183
|
+
for (let index = startIndex; index <= stopIndex; index++) {
|
|
184
|
+
this._getSizeUploadSync(index, isHorizontal);
|
|
185
|
+
}
|
|
186
|
+
}, 0);
|
|
187
|
+
}
|
|
180
188
|
},
|
|
181
189
|
_getSizeUploadSync(index, isHorizontal) {
|
|
182
|
-
const ID = `#${this.$data.id}-${index}`;
|
|
183
190
|
return new Promise((resolve) => {
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
setTimeout(() => {
|
|
195
|
-
getRectSize(ID, success, fail);
|
|
196
|
-
}, 100);
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
getRectSize(ID, success, fail);
|
|
191
|
+
if (index >= 0 && index < this.$props.itemCount) {
|
|
192
|
+
const times = this.itemList.compareSize(index) ? 0 : 2;
|
|
193
|
+
getRectSizeSync(`#${this.preset.id}-${index}`, 100, times).then(({ width, height }) => {
|
|
194
|
+
const size = isHorizontal ? width : height;
|
|
195
|
+
if (typeof size === 'number' && size > 0 && !this.itemList.compareSize(index, size)) {
|
|
196
|
+
this.itemList.setSize(index, size);
|
|
197
|
+
resolve(this.itemList.getSize(index));
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
200
201
|
});
|
|
201
202
|
},
|
|
202
203
|
_getRangeToRender() {
|
|
203
204
|
return this.itemList.getRangeToRender(this.$data.scrollDirection, this.$data.scrollOffset, this.$data.isScrolling);
|
|
204
205
|
},
|
|
205
206
|
_onScrollHorizontal(event) {
|
|
206
|
-
const {
|
|
207
|
+
const { scrollHeight, scrollWidth = this.itemList.getOffsetSizeCache(), scrollTop, scrollLeft, } = event.currentTarget;
|
|
208
|
+
const clientWidth = this.itemList.wrapperSize;
|
|
207
209
|
this.preset.field = {
|
|
208
|
-
scrollHeight
|
|
209
|
-
scrollWidth
|
|
210
|
-
scrollTop
|
|
211
|
-
scrollLeft
|
|
210
|
+
scrollHeight,
|
|
211
|
+
scrollWidth,
|
|
212
|
+
scrollTop,
|
|
213
|
+
scrollLeft,
|
|
212
214
|
clientHeight: scrollHeight,
|
|
213
215
|
clientWidth: scrollWidth
|
|
214
216
|
};
|
|
@@ -246,7 +248,8 @@ var List = {
|
|
|
246
248
|
this.$nextTick(this._resetIsScrollingDebounced);
|
|
247
249
|
},
|
|
248
250
|
_onScrollVertical(event) {
|
|
249
|
-
const {
|
|
251
|
+
const { scrollHeight = this.itemList.getOffsetSizeCache(), scrollWidth, scrollTop, scrollLeft, } = event.currentTarget;
|
|
252
|
+
const clientHeight = this.itemList.wrapperSize;
|
|
250
253
|
if (this.$props.onScrollNative) {
|
|
251
254
|
this.$props.onScrollNative(event);
|
|
252
255
|
}
|
|
@@ -257,11 +260,11 @@ var List = {
|
|
|
257
260
|
// Prevent Safari's elastic scrolling from causing visual shaking when scrolling past bounds.
|
|
258
261
|
const scrollOffset = Math.max(0, Math.min(scrollTop, scrollHeight - clientHeight));
|
|
259
262
|
this.preset.field = {
|
|
260
|
-
scrollHeight
|
|
261
|
-
scrollWidth
|
|
263
|
+
scrollHeight,
|
|
264
|
+
scrollWidth,
|
|
262
265
|
scrollTop: scrollOffset,
|
|
263
|
-
scrollLeft
|
|
264
|
-
clientHeight
|
|
266
|
+
scrollLeft,
|
|
267
|
+
clientHeight,
|
|
265
268
|
clientWidth: scrollWidth,
|
|
266
269
|
diffOffset: this.preset.field.scrollTop - scrollOffset,
|
|
267
270
|
};
|
|
@@ -291,8 +294,97 @@ var List = {
|
|
|
291
294
|
this.resetIsScrollingTimeoutId = null;
|
|
292
295
|
this.isScrolling = false;
|
|
293
296
|
this.$nextTick(() => {
|
|
294
|
-
this.preset.
|
|
297
|
+
this.preset.resetCache();
|
|
295
298
|
});
|
|
299
|
+
},
|
|
300
|
+
getRenderItemNode(index, type = 'node') {
|
|
301
|
+
const { item, itemData, itemKey = defaultItemKey, useIsScrolling } = this.$props;
|
|
302
|
+
const { isScrolling } = this.$data;
|
|
303
|
+
const key = itemKey(index, itemData);
|
|
304
|
+
const style = this.preset.getItemStyle(index);
|
|
305
|
+
if (type === 'placeholder') {
|
|
306
|
+
return render(this.preset.itemElement, {
|
|
307
|
+
key,
|
|
308
|
+
id: `${this.preset.id}-${index}-wrapper`,
|
|
309
|
+
style: this.preset.isBrick ? style : { display: 'none' }
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
return render(this.preset.itemElement, {
|
|
313
|
+
key: itemKey(index, itemData),
|
|
314
|
+
id: `${this.preset.id}-${index}-wrapper`,
|
|
315
|
+
style
|
|
316
|
+
}, render(item, {
|
|
317
|
+
id: `${this.preset.id}-${index}`,
|
|
318
|
+
data: itemData,
|
|
319
|
+
index,
|
|
320
|
+
isScrolling: useIsScrolling ? isScrolling : undefined
|
|
321
|
+
}));
|
|
322
|
+
},
|
|
323
|
+
getRenderColumnNode() {
|
|
324
|
+
const { isScrolling } = this.$data;
|
|
325
|
+
const { innerRef, itemCount } = this.$props;
|
|
326
|
+
const isHorizontal = this.preset.isHorizontal;
|
|
327
|
+
// Read this value AFTER items have been created,
|
|
328
|
+
// So their actual sizes (if variable) are taken into consideration.
|
|
329
|
+
const estimatedTotalSize = convertNumber2PX(this.itemList.getOffsetSize());
|
|
330
|
+
const columnProps = {
|
|
331
|
+
ref: innerRef,
|
|
332
|
+
key: `${this.preset.id}-inner`,
|
|
333
|
+
id: `${this.preset.id}-inner`,
|
|
334
|
+
style: {
|
|
335
|
+
height: isHorizontal ? '100%' : estimatedTotalSize,
|
|
336
|
+
width: !isHorizontal ? '100%' : estimatedTotalSize,
|
|
337
|
+
position: 'relative',
|
|
338
|
+
pointerEvents: isScrolling ? 'none' : 'auto',
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
const [startIndex, stopIndex] = this._getRangeToRender();
|
|
342
|
+
const items = [];
|
|
343
|
+
if (this.preset.isRelative && !this.preset.isBrick) {
|
|
344
|
+
const pre = convertNumber2PX(this.itemList.getOffsetSizeCache(startIndex));
|
|
345
|
+
items.push(render(this.preset.itemElement, {
|
|
346
|
+
key: `${this.preset.id}-pre`,
|
|
347
|
+
id: `${this.preset.id}-pre`,
|
|
348
|
+
style: {
|
|
349
|
+
height: isHorizontal ? '100%' : pre,
|
|
350
|
+
width: !isHorizontal ? '100%' : pre
|
|
351
|
+
}
|
|
352
|
+
}));
|
|
353
|
+
}
|
|
354
|
+
const placeholderCount = this.preset.placeholderCount;
|
|
355
|
+
const restCount = itemCount - stopIndex;
|
|
356
|
+
const prevPlaceholder = startIndex < placeholderCount ? startIndex : placeholderCount;
|
|
357
|
+
const postPlaceholder = restCount < placeholderCount ? restCount : placeholderCount;
|
|
358
|
+
for (let itemIndex = 0; itemIndex < stopIndex + postPlaceholder; itemIndex++) {
|
|
359
|
+
if (!this.preset.isBrick) {
|
|
360
|
+
if (itemIndex < startIndex - prevPlaceholder) {
|
|
361
|
+
itemIndex = startIndex - prevPlaceholder;
|
|
362
|
+
continue;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (itemIndex < startIndex || itemIndex > stopIndex) {
|
|
366
|
+
items.push(this.getRenderItemNode(itemIndex, 'placeholder'));
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
items.push(this.getRenderItemNode(itemIndex));
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return render(this.preset.innerElement, columnProps, items);
|
|
373
|
+
},
|
|
374
|
+
getRenderExpandNodes(direction) {
|
|
375
|
+
const isHorizontal = this.preset.isHorizontal;
|
|
376
|
+
const isRtl = this.preset.isRtl;
|
|
377
|
+
const props = {
|
|
378
|
+
id: `${this.preset.id}-${direction}`,
|
|
379
|
+
style: {
|
|
380
|
+
visibility: 'hidden',
|
|
381
|
+
height: isHorizontal ? '100%' : 100,
|
|
382
|
+
width: isHorizontal ? 100 : '100%',
|
|
383
|
+
[isHorizontal ? isRtl ? 'marginRight' : 'marginLeft' : 'marginTop']: -100,
|
|
384
|
+
zIndex: -1,
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
return render(this.preset.innerElement, props);
|
|
296
388
|
}
|
|
297
389
|
},
|
|
298
390
|
mounted() {
|
|
@@ -307,6 +399,7 @@ var List = {
|
|
|
307
399
|
}
|
|
308
400
|
}
|
|
309
401
|
this._callPropsCallbacks();
|
|
402
|
+
this.preset.boundaryDetection();
|
|
310
403
|
},
|
|
311
404
|
updated() {
|
|
312
405
|
this.preset.update(this.$props);
|
|
@@ -346,54 +439,22 @@ var List = {
|
|
|
346
439
|
if (this.resetIsScrollingTimeoutId !== null) {
|
|
347
440
|
cancelTimeout(this.resetIsScrollingTimeoutId);
|
|
348
441
|
}
|
|
442
|
+
this.preset.dispose();
|
|
349
443
|
},
|
|
350
444
|
render() {
|
|
351
|
-
var _a, _b, _c, _d
|
|
352
|
-
const {
|
|
353
|
-
|
|
445
|
+
var _a, _b, _c, _d;
|
|
446
|
+
const { direction, height, layout, width, enhanced = false } = omit(this.$props, [
|
|
447
|
+
'item', 'itemCount', 'itemData', 'itemKey', 'useIsScrolling',
|
|
448
|
+
'innerElementType', 'innerTagName', 'itemElementType', 'itemTagName',
|
|
449
|
+
'outerElementType', 'outerTagName', 'onScrollToLower', 'onScrollToUpper',
|
|
450
|
+
'upperThreshold', 'lowerThreshold',
|
|
451
|
+
'position', 'innerRef',
|
|
452
|
+
]);
|
|
453
|
+
const { scrollOffset, scrollUpdateWasRequested } = this.$data;
|
|
354
454
|
const isHorizontal = this.preset.isHorizontal;
|
|
355
|
-
const
|
|
356
|
-
const onScroll = isHorizontal
|
|
357
|
-
? this._onScrollHorizontal
|
|
358
|
-
: this._onScrollVertical;
|
|
359
|
-
const [startIndex, stopIndex] = this._getRangeToRender();
|
|
360
|
-
const items = [];
|
|
361
|
-
if (itemCount > 0) {
|
|
362
|
-
const prevPlaceholder = startIndex < placeholderCount ? startIndex : placeholderCount;
|
|
363
|
-
items.push(new Array(prevPlaceholder).fill(-1).map((_, index) => render(this.preset.itemTagName, {
|
|
364
|
-
key: itemKey(index + startIndex - prevPlaceholder, itemData),
|
|
365
|
-
style: { display: 'none' }
|
|
366
|
-
})));
|
|
367
|
-
for (let index = startIndex; index <= stopIndex; index++) {
|
|
368
|
-
const style = this.preset.getItemStyle(index);
|
|
369
|
-
items.push(render(this.preset.itemTagName, {
|
|
370
|
-
key: itemKey(index, itemData),
|
|
371
|
-
style
|
|
372
|
-
}, [
|
|
373
|
-
render(item, {
|
|
374
|
-
id: `${id}-${index}`,
|
|
375
|
-
props: {
|
|
376
|
-
id: `${id}-${index}`,
|
|
377
|
-
data: itemData,
|
|
378
|
-
index,
|
|
379
|
-
isScrolling: useIsScrolling ? isScrolling : undefined
|
|
380
|
-
}
|
|
381
|
-
})
|
|
382
|
-
]));
|
|
383
|
-
}
|
|
384
|
-
let restCount = itemCount - stopIndex;
|
|
385
|
-
restCount = restCount > 0 ? restCount : 0;
|
|
386
|
-
const postPlaceholder = restCount < placeholderCount ? restCount : placeholderCount;
|
|
387
|
-
items.push(new Array(postPlaceholder).fill(-1).map((_, index) => render(this.preset.itemTagName, {
|
|
388
|
-
key: itemKey(1 + index + stopIndex, itemData),
|
|
389
|
-
style: { display: 'none' }
|
|
390
|
-
})));
|
|
391
|
-
}
|
|
392
|
-
// Read this value AFTER items have been created,
|
|
393
|
-
// So their actual sizes (if variable) are taken into consideration.
|
|
394
|
-
const estimatedTotalSize = convertNumber2PX(this.itemList.getOffsetSize());
|
|
455
|
+
const isRtl = this.preset.isRtl;
|
|
395
456
|
const outerElementProps = {
|
|
396
|
-
id,
|
|
457
|
+
id: this.preset.id,
|
|
397
458
|
ref: this._outerRefSetter,
|
|
398
459
|
layout,
|
|
399
460
|
enhanced,
|
|
@@ -407,11 +468,13 @@ var List = {
|
|
|
407
468
|
direction
|
|
408
469
|
},
|
|
409
470
|
attrs: {
|
|
410
|
-
scrollY:
|
|
411
|
-
scrollX:
|
|
471
|
+
scrollY: !this.preset.isHorizontal,
|
|
472
|
+
scrollX: this.preset.isHorizontal
|
|
412
473
|
},
|
|
413
474
|
on: {
|
|
414
|
-
scroll:
|
|
475
|
+
scroll: isHorizontal
|
|
476
|
+
? this._onScrollHorizontal
|
|
477
|
+
: this._onScrollVertical
|
|
415
478
|
}
|
|
416
479
|
};
|
|
417
480
|
if (!enhanced) {
|
|
@@ -422,49 +485,15 @@ var List = {
|
|
|
422
485
|
outerElementProps.scrollTop = scrollUpdateWasRequested ? scrollOffset : this.preset.field.scrollTop;
|
|
423
486
|
}
|
|
424
487
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
style: {
|
|
433
|
-
height: isHorizontal ? '100%' : pre,
|
|
434
|
-
width: !isHorizontal ? '100%' : pre
|
|
435
|
-
}
|
|
436
|
-
}),
|
|
437
|
-
render(this.preset.innerTagName, {
|
|
438
|
-
ref: innerRef,
|
|
439
|
-
key: `${id}-inner`,
|
|
440
|
-
id: `${id}-inner`,
|
|
441
|
-
style: {
|
|
442
|
-
pointerEvents: isScrolling ? 'none' : 'auto',
|
|
443
|
-
position: 'relative',
|
|
444
|
-
}
|
|
445
|
-
}, items),
|
|
446
|
-
process.env.FRAMEWORK === 'vue3' ? (_d = (_c = this.$slots).bottom) === null || _d === void 0 ? void 0 : _d.call(_c) : this.$slots.bottom,
|
|
447
|
-
]);
|
|
448
|
-
}
|
|
449
|
-
else {
|
|
450
|
-
return render(this.preset.outerTagName, outerElementProps, [
|
|
451
|
-
process.env.FRAMEWORK === 'vue3' ? (_f = (_e = this.$slots).top) === null || _f === void 0 ? void 0 : _f.call(_e) : this.$slots.top,
|
|
452
|
-
render(this.preset.innerTagName, {
|
|
453
|
-
ref: innerRef,
|
|
454
|
-
key: `${id}-inner`,
|
|
455
|
-
id: `${id}-inner`,
|
|
456
|
-
style: {
|
|
457
|
-
height: isHorizontal ? '100%' : estimatedTotalSize,
|
|
458
|
-
pointerEvents: isScrolling ? 'none' : 'auto',
|
|
459
|
-
position: 'relative',
|
|
460
|
-
width: !isHorizontal ? '100%' : estimatedTotalSize
|
|
461
|
-
}
|
|
462
|
-
}, items),
|
|
463
|
-
process.env.FRAMEWORK === 'vue3' ? (_h = (_g = this.$slots).bottom) === null || _h === void 0 ? void 0 : _h.call(_g) : this.$slots.bottom,
|
|
464
|
-
]);
|
|
465
|
-
}
|
|
488
|
+
return render(this.preset.outerElement, outerElementProps, [
|
|
489
|
+
this.getRenderExpandNodes(isHorizontal ? isRtl ? 'right' : 'left' : 'top'),
|
|
490
|
+
process.env.FRAMEWORK === 'vue3' ? (_b = (_a = this.$slots).top) === null || _b === void 0 ? void 0 : _b.call(_a) : this.$slots.top,
|
|
491
|
+
this.getRenderColumnNode(),
|
|
492
|
+
process.env.FRAMEWORK === 'vue3' ? (_d = (_c = this.$slots).bottom) === null || _d === void 0 ? void 0 : _d.call(_c) : this.$slots.bottom,
|
|
493
|
+
this.getRenderExpandNodes(isHorizontal ? isRtl ? 'left' : 'right' : 'bottom'),
|
|
494
|
+
]);
|
|
466
495
|
}
|
|
467
|
-
};
|
|
496
|
+
});
|
|
468
497
|
|
|
469
498
|
export { List as default };
|
|
470
499
|
//# sourceMappingURL=list.js.map
|