@rdlabo/ngx-cdk-scroll-strategies 21.2.0-6 → 21.2.0-8
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/README.md
CHANGED
|
@@ -14,8 +14,9 @@ This is a simple coding concept:
|
|
|
14
14
|
|
|
15
15
|
Use `[itemDynamicSizes]` directive instead of `[itemSize]` or `[autosize]` directive. `[itemDynamicSizes]` value's type is `itemDynamicSize[]`.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
Every data item must have one corresponding `itemDynamicSizes` entry in the same order. Each `itemSize` must be a finite number greater than zero. If Angular updates the data and size signals in separate turns, the strategy keeps the last complete geometry until their lengths match; it never estimates unknown heights.
|
|
18
18
|
|
|
19
|
+
This library is based largely on this blog: https://dev.to/georgii/virtual-scrolling-of-content-with-variable-height-with-angular-3a52
|
|
19
20
|
|
|
20
21
|
## Installation
|
|
21
22
|
|
|
@@ -67,7 +68,6 @@ Other than this, it works the same way as `@angular/cdk/scrolling`.
|
|
|
67
68
|
- Demo: https://rdlabo-ionic-angular-library.netlify.app/main/scroll-strategies/advanced
|
|
68
69
|
- Source: https://github.com/rdlabo-team/ionic-angular-library/blob/main/projects/demo/src/app/scroll-strategies/pages/scroll-advanced
|
|
69
70
|
|
|
70
|
-
|
|
71
71
|
### Reverse Usage
|
|
72
72
|
|
|
73
73
|
> This is a demo for reverse scrolling like WeChat.
|
|
@@ -120,8 +120,10 @@ div.reverse-items {
|
|
|
120
120
|
}
|
|
121
121
|
```
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
https://github.com/rdlabo-team/ionic-angular-library/blob/main/projects/scroll-strategies/src/lib/dynamic-size-virtual-scroll-strategy.ts
|
|
123
|
+
**In Reverse Scroll, CdkVirtualScrollViewport's measureScrollOffset does not work. Please use the scrollOffset of this directive.**
|
|
124
|
+
https://github.com/rdlabo-team/ionic-angular-library/blob/main/projects/scroll-strategies/src/lib/dynamic-size-virtual-scroll-strategy.ts
|
|
125
|
+
|
|
126
|
+
The reverse layout uses negative native `scrollTop` values. `scrollToIndex()` accepts a logical item index as usual and converts its cumulative offset to that native coordinate internally.
|
|
125
127
|
|
|
126
128
|
### Optional
|
|
127
129
|
|
|
@@ -134,6 +136,7 @@ import { DynamicSizeVirtualScrollService } from '@rdlabo/ngx-cdk-scroll-strategi
|
|
|
134
136
|
Detail is here: https://github.com/rdlabo-team/ionic-angular-library/blob/main/projects/scroll-strategies/src/lib/dynamic-size-virtual-scroll.service.ts
|
|
135
137
|
|
|
136
138
|
## FQA
|
|
139
|
+
|
|
137
140
|
### Why don't use `autosize` directive?
|
|
138
141
|
|
|
139
142
|
`autosize` directive use average item size. This is not support "item size is changed" "item is removed". Because don't have item size cache.
|
|
@@ -117,11 +117,138 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImpo
|
|
|
117
117
|
}]
|
|
118
118
|
}] });
|
|
119
119
|
|
|
120
|
+
/** Returns the cumulative size of all items before `endIndex`. */
|
|
121
|
+
const sumItemSize = (dynamicSize, endIndex) => {
|
|
122
|
+
return dynamicSize.slice(0, endIndex).reduce((acc, item) => acc + item.itemSize, 0);
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Retains the package's legacy pixel-to-index calculation for compatibility.
|
|
126
|
+
* @deprecated Use `calculateItemCountForPixelDistance` for mathematically continuous results.
|
|
127
|
+
*/
|
|
128
|
+
const calcIndex = (dynamicSize, itemSizeRange, startIndex = 0, isReverse = false) => {
|
|
129
|
+
let sum = 0;
|
|
130
|
+
let diffIndex = 0;
|
|
131
|
+
const item = isReverse ? [...dynamicSize].reverse() : dynamicSize;
|
|
132
|
+
if (isReverse) {
|
|
133
|
+
startIndex = dynamicSize.length - startIndex;
|
|
134
|
+
}
|
|
135
|
+
const calculatedIndex = item.reduce((acc, currentValue, index) => {
|
|
136
|
+
if (index < startIndex || acc !== -1) {
|
|
137
|
+
return acc;
|
|
138
|
+
}
|
|
139
|
+
sum += currentValue.itemSize;
|
|
140
|
+
if (sum >= itemSizeRange) {
|
|
141
|
+
if (sum === itemSizeRange) {
|
|
142
|
+
return index - startIndex;
|
|
143
|
+
}
|
|
144
|
+
const diff = sum - itemSizeRange;
|
|
145
|
+
const getOver = item[index].itemSize - diff;
|
|
146
|
+
diffIndex = getOver / item[index].itemSize;
|
|
147
|
+
return Math.max(0, index - 1 + diffIndex - startIndex);
|
|
148
|
+
}
|
|
149
|
+
if (index === item.length - 1) {
|
|
150
|
+
return index - startIndex + 1;
|
|
151
|
+
}
|
|
152
|
+
return acc;
|
|
153
|
+
}, -1);
|
|
154
|
+
return calculatedIndex === -1 ? 0 : calculatedIndex;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Converts a pixel distance into an exact fractional item count.
|
|
158
|
+
*
|
|
159
|
+
* Forward measurement starts at `startIndex`. Reverse measurement starts immediately before
|
|
160
|
+
* `startIndex`, matching the items that precede a rendered range. The result is bounded by the
|
|
161
|
+
* number of available items in that direction.
|
|
162
|
+
*/
|
|
163
|
+
const calculateItemCountForPixelDistance = (dynamicSize, itemSizeRange, startIndex = 0, isReverse = false) => {
|
|
164
|
+
let remaining = Math.max(0, itemSizeRange);
|
|
165
|
+
let count = 0;
|
|
166
|
+
let index = isReverse ? Math.min(dynamicSize.length, Math.max(0, Math.trunc(startIndex))) - 1 : Math.max(0, Math.trunc(startIndex));
|
|
167
|
+
const step = isReverse ? -1 : 1;
|
|
168
|
+
while (index >= 0 && index < dynamicSize.length && remaining > 0) {
|
|
169
|
+
const size = dynamicSize[index].itemSize;
|
|
170
|
+
if (remaining < size) {
|
|
171
|
+
return count + remaining / size;
|
|
172
|
+
}
|
|
173
|
+
remaining -= size;
|
|
174
|
+
count += 1;
|
|
175
|
+
index += step;
|
|
176
|
+
}
|
|
177
|
+
return count;
|
|
178
|
+
};
|
|
179
|
+
/** Builds cumulative item boundaries from zero through `length`. */
|
|
180
|
+
const createPrefixSums = (dynamicSize, length) => {
|
|
181
|
+
const prefixSums = new Array(length + 1);
|
|
182
|
+
prefixSums[0] = 0;
|
|
183
|
+
for (let index = 0; index < length; index += 1) {
|
|
184
|
+
prefixSums[index + 1] = prefixSums[index] + dynamicSize[index].itemSize;
|
|
185
|
+
}
|
|
186
|
+
return prefixSums;
|
|
187
|
+
};
|
|
188
|
+
const lowerBound = (values, target) => {
|
|
189
|
+
let low = 0;
|
|
190
|
+
let high = values.length;
|
|
191
|
+
while (low < high) {
|
|
192
|
+
const middle = low + Math.floor((high - low) / 2);
|
|
193
|
+
if (values[middle] < target) {
|
|
194
|
+
low = middle + 1;
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
high = middle;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
return low;
|
|
201
|
+
};
|
|
202
|
+
const upperBound = (values, target) => {
|
|
203
|
+
let low = 0;
|
|
204
|
+
let high = values.length;
|
|
205
|
+
while (low < high) {
|
|
206
|
+
const middle = low + Math.floor((high - low) / 2);
|
|
207
|
+
if (values[middle] <= target) {
|
|
208
|
+
low = middle + 1;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
high = middle;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return low;
|
|
215
|
+
};
|
|
216
|
+
/** Returns the item containing `offset`, choosing the next item at an exact boundary. */
|
|
217
|
+
const indexAtOffset = (prefixSums, offset) => {
|
|
218
|
+
const itemCount = prefixSums.length - 1;
|
|
219
|
+
return Math.min(itemCount - 1, Math.max(0, upperBound(prefixSums, offset) - 1));
|
|
220
|
+
};
|
|
221
|
+
/** Returns the earliest rendered index whose boundary supplies the requested start buffer. */
|
|
222
|
+
const startIndexForOffset = (prefixSums, offset) => {
|
|
223
|
+
const itemCount = prefixSums.length - 1;
|
|
224
|
+
return Math.min(itemCount - 1, Math.max(0, upperBound(prefixSums, offset) - 1));
|
|
225
|
+
};
|
|
226
|
+
/** Returns the exclusive rendered end index whose boundary covers `offset`. */
|
|
227
|
+
const endIndexForOffset = (prefixSums, offset) => {
|
|
228
|
+
return Math.min(prefixSums.length - 1, Math.max(1, lowerBound(prefixSums, offset)));
|
|
229
|
+
};
|
|
230
|
+
/** Mutates a rendered range so it covers the viewport plus equal start and end buffers. */
|
|
231
|
+
const setRangeForBuffer = (range, prefixSums, scrollOffset, viewportSize, bufferPx) => {
|
|
232
|
+
range.start = startIndexForOffset(prefixSums, scrollOffset - bufferPx);
|
|
233
|
+
range.end = endIndexForOffset(prefixSums, scrollOffset + viewportSize + bufferPx);
|
|
234
|
+
};
|
|
235
|
+
/** Validates item sizes and virtual scroll buffer configuration. */
|
|
236
|
+
const validateConfiguration = (dynamicSize, minBufferPx, maxBufferPx) => {
|
|
237
|
+
if (!Number.isFinite(minBufferPx) || minBufferPx < 0 || !Number.isFinite(maxBufferPx) || maxBufferPx < minBufferPx) {
|
|
238
|
+
throw Error('CDK virtual scroll: buffers must be finite, non-negative, and maxBufferPx must be greater than or equal to minBufferPx');
|
|
239
|
+
}
|
|
240
|
+
dynamicSize.forEach(({ itemSize }, index) => {
|
|
241
|
+
if (!Number.isFinite(itemSize) || itemSize <= 0) {
|
|
242
|
+
throw Error(`CDK virtual scroll: item size at index ${index} must be a finite number greater than zero`);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
};
|
|
246
|
+
|
|
120
247
|
/**
|
|
121
248
|
*
|
|
122
249
|
* https://github.com/angular/components/blob/main/src/cdk/scrolling/fixed-size-virtual-scroll.ts
|
|
123
250
|
*/
|
|
124
|
-
/** Virtual scrolling strategy for lists
|
|
251
|
+
/** Virtual scrolling strategy for lists whose item sizes are known in advance. */
|
|
125
252
|
class DynamicSizeVirtualScrollStrategy {
|
|
126
253
|
/**
|
|
127
254
|
* @param itemSize The size of the items in the virtually scrolling list.
|
|
@@ -135,9 +262,12 @@ class DynamicSizeVirtualScrollStrategy {
|
|
|
135
262
|
this.scrolledIndexChange = this._scrolledIndexChange.pipe(distinctUntilChanged());
|
|
136
263
|
/** The attached viewport. */
|
|
137
264
|
this._viewport = null;
|
|
265
|
+
/** Cumulative item boundaries. Rebuilt only when the size model or data length changes. */
|
|
266
|
+
this._prefixSums = [0];
|
|
267
|
+
this._prefixDataLength = -1;
|
|
268
|
+
/** Last normalized scroll offset, exposed because CDK cannot measure the reverse layout. */
|
|
138
269
|
this.measureScrollOffset = 0;
|
|
139
|
-
|
|
140
|
-
this._latestDataLength = 0;
|
|
270
|
+
validateConfiguration(itemSize, minBufferPx, maxBufferPx);
|
|
141
271
|
this._itemDynamicSize = itemSize;
|
|
142
272
|
this._minBufferPx = minBufferPx;
|
|
143
273
|
this._maxBufferPx = maxBufferPx;
|
|
@@ -165,10 +295,9 @@ class DynamicSizeVirtualScrollStrategy {
|
|
|
165
295
|
* @param isReverse
|
|
166
296
|
*/
|
|
167
297
|
updateItemAndBufferSize(itemDynamicSize, minBufferPx, maxBufferPx, isReverse) {
|
|
168
|
-
|
|
169
|
-
throw Error('CDK virtual scroll: maxBufferPx must be greater than or equal to minBufferPx');
|
|
170
|
-
}
|
|
298
|
+
validateConfiguration(itemDynamicSize, minBufferPx, maxBufferPx);
|
|
171
299
|
this._itemDynamicSize = itemDynamicSize;
|
|
300
|
+
this._prefixDataLength = -1;
|
|
172
301
|
this._minBufferPx = minBufferPx;
|
|
173
302
|
this._maxBufferPx = maxBufferPx;
|
|
174
303
|
this._isReverse = isReverse;
|
|
@@ -199,8 +328,13 @@ class DynamicSizeVirtualScrollStrategy {
|
|
|
199
328
|
*/
|
|
200
329
|
scrollToIndex(index, behavior) {
|
|
201
330
|
if (this._viewport) {
|
|
202
|
-
|
|
203
|
-
|
|
331
|
+
if (!this._hasCompleteSizeModel(this._viewport.getDataLength())) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const prefixSums = this._getPrefixSums(this._viewport.getDataLength());
|
|
335
|
+
const boundedIndex = Math.min(prefixSums.length - 1, Math.max(0, Math.trunc(index)));
|
|
336
|
+
const offset = prefixSums[boundedIndex];
|
|
337
|
+
this._viewport.scrollToOffset(this._isReverse ? -offset : offset, behavior);
|
|
204
338
|
}
|
|
205
339
|
}
|
|
206
340
|
/** Update the viewport's total content size. */
|
|
@@ -208,8 +342,16 @@ class DynamicSizeVirtualScrollStrategy {
|
|
|
208
342
|
if (!this._viewport) {
|
|
209
343
|
return;
|
|
210
344
|
}
|
|
211
|
-
const
|
|
212
|
-
|
|
345
|
+
const dataLength = this._viewport.getDataLength();
|
|
346
|
+
if (dataLength === 0) {
|
|
347
|
+
this._viewport.setTotalContentSize(0);
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
if (!this._hasCompleteSizeModel(dataLength)) {
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
const prefixSums = this._getPrefixSums(dataLength);
|
|
354
|
+
this._viewport.setTotalContentSize(prefixSums[prefixSums.length - 1]);
|
|
213
355
|
}
|
|
214
356
|
/** Update the viewport's rendered range. */
|
|
215
357
|
_updateRenderedRange() {
|
|
@@ -225,100 +367,75 @@ class DynamicSizeVirtualScrollStrategy {
|
|
|
225
367
|
const newRange = { start: renderedRange.start, end: renderedRange.end };
|
|
226
368
|
const viewportSize = this._viewport.getViewportSize();
|
|
227
369
|
const dataLength = this._viewport.getDataLength();
|
|
370
|
+
if (dataLength === 0) {
|
|
371
|
+
this._viewport.setRenderedRange({ start: 0, end: 0 });
|
|
372
|
+
this._viewport.setRenderedContentOffset(0);
|
|
373
|
+
this.measureScrollOffset = 0;
|
|
374
|
+
this._scrolledIndexChange.next(0);
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
// Angular can update cdkVirtualForOf and itemDynamicSizes in separate turns. A partial size
|
|
378
|
+
// model cannot define an exact total height or offset, so retain the last complete geometry
|
|
379
|
+
// until both lengths agree. On first attachment, render one item so a measuring consumer can
|
|
380
|
+
// obtain its initial size.
|
|
381
|
+
if (!this._hasCompleteSizeModel(dataLength)) {
|
|
382
|
+
if (newRange.start === 0 && newRange.end === 0) {
|
|
383
|
+
this._viewport.setRenderedRange({ start: 0, end: 1 });
|
|
384
|
+
this._viewport.setRenderedContentOffset(0);
|
|
385
|
+
}
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const prefixSums = this._getPrefixSums(dataLength);
|
|
389
|
+
const totalContentSize = prefixSums[dataLength];
|
|
228
390
|
// Reverse offset if _isReverse
|
|
229
|
-
|
|
391
|
+
const measuredScrollOffset = !this._isReverse
|
|
230
392
|
? this._viewport.measureScrollOffset()
|
|
231
393
|
: Math.max(0, this._viewport.getElementRef().nativeElement.scrollTop * -1);
|
|
232
|
-
//
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
// If first visible index changed we must update scroll offset to handle start/end buffers
|
|
240
|
-
// Current range must also be adjusted to cover the new position (bottom of new list).
|
|
241
|
-
if (firstVisibleIndex != newVisibleIndex) {
|
|
242
|
-
firstVisibleIndex = newVisibleIndex;
|
|
243
|
-
// scrollOffset = newVisibleIndex * this._itemDynamicSize;
|
|
244
|
-
scrollOffset = sumItemSize(this._itemDynamicSize, newVisibleIndex);
|
|
245
|
-
newRange.start = Math.floor(firstVisibleIndex);
|
|
246
|
-
}
|
|
247
|
-
newRange.end = Math.max(0, Math.min(dataLength, newRange.start + maxVisibleItems));
|
|
248
|
-
}
|
|
249
|
-
// const startBuffer = scrollOffset - newRange.start * this._itemDynamicSize;
|
|
250
|
-
const startBuffer = scrollOffset - sumItemSize(this._itemDynamicSize, newRange.start);
|
|
251
|
-
if (startBuffer < this._minBufferPx && newRange.start != 0) {
|
|
252
|
-
// const expandStart = Math.ceil((this._maxBufferPx - startBuffer) / this._itemDynamicSize);
|
|
253
|
-
const expandStart = Math.ceil(calcIndex(this._itemDynamicSize, this._maxBufferPx - startBuffer, newRange.start, true));
|
|
254
|
-
newRange.start = Math.max(0, newRange.start - expandStart);
|
|
255
|
-
// newRange.end = Math.min(dataLength, Math.ceil(firstVisibleIndex + (viewportSize + this._minBufferPx) / this._itemDynamicSize));
|
|
256
|
-
newRange.end = Math.min(dataLength, Math.ceil(firstVisibleIndex + calcIndex(this._itemDynamicSize, viewportSize + this._minBufferPx, firstVisibleIndex)) + 1);
|
|
257
|
-
// console.log(
|
|
258
|
-
// 'expandStart',
|
|
259
|
-
// firstVisibleIndex,
|
|
260
|
-
// '"' + newRange.start + '-' + newRange.end + '"',
|
|
261
|
-
// dataLength,
|
|
262
|
-
// viewportSize + this._minBufferPx,
|
|
263
|
-
// Math.ceil(firstVisibleIndex + calcIndex(this._itemDynamicSize, viewportSize + this._minBufferPx, firstVisibleIndex)),
|
|
264
|
-
// );
|
|
394
|
+
// The browser clamps the actual offset to this interval. Applying the same clamp immediately
|
|
395
|
+
// also makes a data-length shrink deterministic before the next native scroll event.
|
|
396
|
+
const scrollOffset = Math.min(Math.max(0, measuredScrollOffset), Math.max(0, totalContentSize - viewportSize));
|
|
397
|
+
const firstVisibleIndex = indexAtOffset(prefixSums, scrollOffset);
|
|
398
|
+
const rangeIsInvalid = newRange.start < 0 || newRange.start >= newRange.end || newRange.end > dataLength;
|
|
399
|
+
if (rangeIsInvalid) {
|
|
400
|
+
setRangeForBuffer(newRange, prefixSums, scrollOffset, viewportSize, this._maxBufferPx);
|
|
265
401
|
}
|
|
266
402
|
else {
|
|
267
|
-
|
|
268
|
-
const endBuffer =
|
|
269
|
-
if (
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (expandEnd > 0) {
|
|
273
|
-
newRange.end = Math.min(dataLength, newRange.end + expandEnd);
|
|
274
|
-
// Math.floor(firstVisibleIndex - this._minBufferPx / this._itemSize),
|
|
275
|
-
newRange.start = Math.max(0, Math.floor(firstVisibleIndex - calcIndex(this._itemDynamicSize, this._minBufferPx, firstVisibleIndex, true)));
|
|
276
|
-
// console.log(
|
|
277
|
-
// 'expandEnd',
|
|
278
|
-
// firstVisibleIndex,
|
|
279
|
-
// '"' + newRange.start + '-' + newRange.end + '"',
|
|
280
|
-
// dataLength,
|
|
281
|
-
// Math.ceil(firstVisibleIndex + calcIndex(this._itemDynamicSize, viewportSize + this._minBufferPx, firstVisibleIndex)),
|
|
282
|
-
// );
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
if (newRange.start === 0 && newRange.end === 0 && dataLength > 0) {
|
|
287
|
-
// Have items but not rendered yet.
|
|
288
|
-
// This can happen when itemDynamicSizes is still empty while dataLength is already available.
|
|
289
|
-
// Use the same policy as the initial render in fixed-size virtual scroll: viewport + maxBuffer.
|
|
290
|
-
if (this._itemDynamicSize.length === 0) {
|
|
291
|
-
newRange.end = Math.min(dataLength, 1);
|
|
403
|
+
const startBuffer = scrollOffset - prefixSums[newRange.start];
|
|
404
|
+
const endBuffer = prefixSums[newRange.end] - (scrollOffset + viewportSize);
|
|
405
|
+
if (startBuffer < this._minBufferPx && newRange.start > 0) {
|
|
406
|
+
newRange.start = startIndexForOffset(prefixSums, scrollOffset - this._maxBufferPx);
|
|
407
|
+
newRange.end = endIndexForOffset(prefixSums, scrollOffset + viewportSize + this._minBufferPx);
|
|
292
408
|
}
|
|
293
|
-
else {
|
|
294
|
-
|
|
295
|
-
newRange.
|
|
409
|
+
else if (endBuffer < this._minBufferPx && newRange.end < dataLength) {
|
|
410
|
+
newRange.end = endIndexForOffset(prefixSums, scrollOffset + viewportSize + this._maxBufferPx);
|
|
411
|
+
newRange.start = startIndexForOffset(prefixSums, scrollOffset - this._minBufferPx);
|
|
296
412
|
}
|
|
297
413
|
}
|
|
298
|
-
if (firstVisibleIndex === 0 && newRange.start > firstVisibleIndex) {
|
|
299
|
-
// This is bug fix. If newRange.start > firstVisibleIndex, can't visible '0'
|
|
300
|
-
newRange.start = firstVisibleIndex;
|
|
301
|
-
}
|
|
302
|
-
if (newRange.start > newRange.end) {
|
|
303
|
-
// This is bug fix. If newRange.start > newRange.end, it will cause infinite loop.
|
|
304
|
-
newRange.end = Math.min(dataLength, Math.ceil(newRange.start + calcIndex(this._itemDynamicSize, viewportSize + this._minBufferPx, newRange.start)));
|
|
305
|
-
}
|
|
306
414
|
this._viewport.setRenderedRange(newRange);
|
|
307
|
-
// this._viewport.setRenderedContentOffset(this._itemDynamicSize * newRange.start);
|
|
308
415
|
if (!this._isReverse) {
|
|
309
|
-
this._viewport.setRenderedContentOffset(
|
|
416
|
+
this._viewport.setRenderedContentOffset(prefixSums[newRange.start]);
|
|
310
417
|
}
|
|
311
418
|
else {
|
|
312
|
-
let offset = Math.min(0,
|
|
419
|
+
let offset = Math.min(0, prefixSums[newRange.start] * -1);
|
|
313
420
|
if (offset === 0) {
|
|
314
421
|
offset = 0;
|
|
315
422
|
}
|
|
316
423
|
this._viewport.setRenderedContentOffset(offset);
|
|
317
424
|
}
|
|
318
425
|
this.measureScrollOffset = scrollOffset;
|
|
319
|
-
this._latestDataLength = dataLength;
|
|
320
426
|
this._scrolledIndexChange.next(firstVisibleIndex);
|
|
321
427
|
}
|
|
428
|
+
_getPrefixSums(dataLength) {
|
|
429
|
+
const modeledLength = dataLength;
|
|
430
|
+
if (modeledLength !== this._prefixDataLength) {
|
|
431
|
+
this._prefixSums = createPrefixSums(this._itemDynamicSize, modeledLength);
|
|
432
|
+
this._prefixDataLength = modeledLength;
|
|
433
|
+
}
|
|
434
|
+
return this._prefixSums;
|
|
435
|
+
}
|
|
436
|
+
_hasCompleteSizeModel(dataLength) {
|
|
437
|
+
return this._itemDynamicSize.length === dataLength;
|
|
438
|
+
}
|
|
322
439
|
}
|
|
323
440
|
/**
|
|
324
441
|
* Provider factory for `FixedSizeVirtualScrollStrategy` that simply extracts the already created
|
|
@@ -329,46 +446,7 @@ class DynamicSizeVirtualScrollStrategy {
|
|
|
329
446
|
function _dynamicSizeVirtualScrollStrategyFactory(fixedSizeDir) {
|
|
330
447
|
return fixedSizeDir._scrollStrategy;
|
|
331
448
|
}
|
|
332
|
-
|
|
333
|
-
return dynamicSize.slice(0, endIndex).reduce((acc, item) => acc + item.itemSize, 0);
|
|
334
|
-
};
|
|
335
|
-
/**
|
|
336
|
-
* TODO: 計算方法の見直し
|
|
337
|
-
* 0.5 = 0個目の半分はマイナスの計算が生まれるため、1個目からカウント
|
|
338
|
-
*/
|
|
339
|
-
const calcIndex = (dynamicSize, itemSizeRange, startIndex = 0, isReverse = false) => {
|
|
340
|
-
let sum = 0;
|
|
341
|
-
let diffIndex = 0;
|
|
342
|
-
const item = isReverse ? structuredClone(dynamicSize).reverse() : dynamicSize;
|
|
343
|
-
if (isReverse) {
|
|
344
|
-
startIndex = dynamicSize.length - startIndex;
|
|
345
|
-
}
|
|
346
|
-
const calcIndex = item.reduce((acc, currentValue, index) => {
|
|
347
|
-
if (index < startIndex) {
|
|
348
|
-
return acc;
|
|
349
|
-
}
|
|
350
|
-
if (acc !== -1) {
|
|
351
|
-
// 既に見つかった場合、何もしない
|
|
352
|
-
return acc;
|
|
353
|
-
}
|
|
354
|
-
sum += currentValue.itemSize;
|
|
355
|
-
if (sum >= itemSizeRange) {
|
|
356
|
-
if (sum === itemSizeRange) {
|
|
357
|
-
return index - startIndex;
|
|
358
|
-
}
|
|
359
|
-
const diff = sum - itemSizeRange;
|
|
360
|
-
const getOver = item[index].itemSize - diff;
|
|
361
|
-
diffIndex = getOver / item[index].itemSize;
|
|
362
|
-
return Math.max(0, index - 1 + diffIndex - startIndex);
|
|
363
|
-
}
|
|
364
|
-
else if (index === item.length - 1) {
|
|
365
|
-
return index - startIndex + 1;
|
|
366
|
-
}
|
|
367
|
-
return acc;
|
|
368
|
-
}, -1);
|
|
369
|
-
return calcIndex === -1 ? 0 : calcIndex;
|
|
370
|
-
};
|
|
371
|
-
/** A virtual scroll strategy that supports fixed-size items. */
|
|
449
|
+
/** Directive that installs dynamic-size virtual scrolling on a CDK viewport. */
|
|
372
450
|
class CdkDynamicSizeVirtualScroll {
|
|
373
451
|
constructor() {
|
|
374
452
|
this.el = inject(ElementRef);
|
|
@@ -430,5 +508,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImpo
|
|
|
430
508
|
* Generated bundle index. Do not edit.
|
|
431
509
|
*/
|
|
432
510
|
|
|
433
|
-
export { CdkDynamicSizeVirtualScroll, DynamicSizeVirtualScrollService, DynamicSizeVirtualScrollStrategy, _dynamicSizeVirtualScrollStrategyFactory, calcIndex, sumItemSize };
|
|
511
|
+
export { CdkDynamicSizeVirtualScroll, DynamicSizeVirtualScrollService, DynamicSizeVirtualScrollStrategy, _dynamicSizeVirtualScrollStrategyFactory, calcIndex, calculateItemCountForPixelDistance, sumItemSize };
|
|
434
512
|
//# sourceMappingURL=rdlabo-ngx-cdk-scroll-strategies.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rdlabo-ngx-cdk-scroll-strategies.mjs","sources":["../../../projects/scroll-strategies/src/lib/dynamic-size-virtual-scroll.service.ts","../../../projects/scroll-strategies/src/lib/dynamic-size-virtual-scroll-strategy.ts","../../../projects/scroll-strategies/src/public-api.ts","../../../projects/scroll-strategies/src/rdlabo-ngx-cdk-scroll-strategies.ts"],"sourcesContent":["import { computed, Injectable, Signal } from '@angular/core';\nimport { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';\nimport { itemDynamicSize } from './dynamic-size-virtual-scroll-strategy';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DynamicSizeVirtualScrollService {\n readonly mergeScrollY = 160;\n\n /*\n * iOS smooth scroll can scroll after transition end.\n * In this case, sometimes Virtual Scroll is white screen.\n * Scroll amount restoration prevents this.\n */\n onInit(virtualScroll: CdkVirtualScrollViewport, latestScrollOffset: number) {\n if (latestScrollOffset > 0) {\n virtualScroll.scrollToOffset(latestScrollOffset);\n }\n }\n\n /**\n * Save scroll amount for next view enter.\n */\n onDestroy(virtualScroll: CdkVirtualScrollViewport): number {\n return virtualScroll.measureScrollOffset('top');\n }\n\n /**\n * Change itemDynamicSize[] to style.height[].\n * require itemDynamicSize has 'source' and 'itemSize'.\n */\n getBindDynamicItemHeight($calcDynamicItemSize: Signal<itemDynamicSize[]>): Signal<string[]> {\n return computed<string[]>(() => {\n return $calcDynamicItemSize().map((item) => {\n return item['source'] === 'temporary' ? 'auto' : item.itemSize + 'px';\n });\n });\n }\n\n /**\n * If change the array of hidden areas during scrolling,\n * a layout shift will occur. (If not reverse, refers to the array located above the display area.)\n * This function confirms that it is OK to change the array.\n */\n isEnableMerge(virtualScroll: CdkVirtualScrollViewport): boolean {\n return virtualScroll.getRenderedRange().start === 0 && virtualScroll.measureScrollOffset('top') < this.mergeScrollY;\n }\n\n /**\n * When an array is destructively replaced,\n * the height of the viewport may remain the same as the sum of the previous array.\n * This force it to be initialized.\n */\n refreshViewport(virtualScroll: CdkVirtualScrollViewport): void {\n virtualScroll.scrollToOffset(0);\n virtualScroll.setRenderedContentOffset(0);\n virtualScroll.setRenderedRange({ start: 0, end: 0 });\n }\n\n /**\n * This is for smooth scrolling to the top.\n */\n async scrollToTopSmooth(virtualScroll: CdkVirtualScrollViewport): Promise<void> {\n await this.scrollToPoint(virtualScroll, 0, 0, 400);\n }\n\n /**\n * This is for smooth scrolling to a specific point.\n * https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/content/content.tsx#L357C3-L404C4\n */\n async scrollToPoint(\n el: CdkVirtualScrollViewport,\n x: number | undefined | null,\n y: number | undefined | null,\n duration = 0,\n ): Promise<void> {\n if (duration < 32) {\n if (y != null) {\n el.scrollToOffset(y);\n }\n if (x != null) {\n el.scrollToOffset(x);\n }\n return;\n }\n\n let resolve!: () => void;\n let startTime = 0;\n const promise = new Promise<void>((r) => (resolve = r));\n const fromY = el.measureScrollOffset('top');\n const fromX = el.measureScrollOffset('left');\n\n const deltaY = y != null ? y - fromY : 0;\n const deltaX = x != null ? x - fromX : 0;\n\n // scroll loop\n const step = (timeStamp: number) => {\n const linearTime = Math.min(1, (timeStamp - startTime) / duration) - 1;\n const easedT = Math.pow(linearTime, 3) + 1;\n\n if (deltaY !== 0) {\n el.scrollToOffset(Math.floor(easedT * deltaY + fromY));\n }\n if (deltaX !== 0) {\n el.scrollToOffset(Math.floor(easedT * deltaX + fromX));\n }\n\n if (easedT < 1) {\n // do not use DomController here\n // must use nativeRaf in order to fire in the next frame\n requestAnimationFrame(step);\n } else {\n resolve();\n }\n };\n // chill out for a frame first\n requestAnimationFrame((ts) => {\n startTime = ts;\n step(ts);\n });\n return promise;\n }\n}\n","/**\n *\n * https://github.com/angular/components/blob/main/src/cdk/scrolling/fixed-size-virtual-scroll.ts\n */\n\nimport { BooleanInput, coerceArray, coerceBooleanProperty, coerceNumberProperty, NumberInput } from '@angular/cdk/coercion';\nimport { Directive, effect, ElementRef, forwardRef, inject, input } from '@angular/core';\nimport { Observable, Subject } from 'rxjs';\nimport { distinctUntilChanged } from 'rxjs/operators';\nimport { CdkVirtualScrollViewport, VIRTUAL_SCROLL_STRATEGY, VirtualScrollStrategy } from '@angular/cdk/scrolling';\n\n/** Virtual scrolling strategy for lists with items of known fixed size. */\nexport class DynamicSizeVirtualScrollStrategy implements VirtualScrollStrategy {\n private readonly _scrolledIndexChange = new Subject<number>();\n\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n scrolledIndexChange: Observable<number> = this._scrolledIndexChange.pipe(distinctUntilChanged());\n\n /** The attached viewport. */\n private _viewport: CdkVirtualScrollViewport | null = null;\n\n /** The size of the items in the virtually scrolling list. */\n private _itemDynamicSize: itemDynamicSize[];\n\n /** The minimum amount of buffer rendered beyond the viewport (in pixels). */\n private _minBufferPx: number;\n\n /** The number of buffer items to render beyond the edge of the viewport (in pixels). */\n private _maxBufferPx: number;\n\n /** This is added for reverse virtual scroll **/\n private _isReverse: boolean;\n measureScrollOffset = 0;\n\n /** This is added for change dataLength **/\n private _latestDataLength = 0;\n\n /**\n * @param itemSize The size of the items in the virtually scrolling list.\n * @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more\n * @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.\n * @param isReverse Added from rdlabo for reverse\n */\n constructor(itemSize: itemDynamicSize[], minBufferPx: number, maxBufferPx: number, isReverse: boolean) {\n this._itemDynamicSize = itemSize;\n this._minBufferPx = minBufferPx;\n this._maxBufferPx = maxBufferPx;\n this._isReverse = isReverse;\n }\n\n /**\n * Attaches this scroll strategy to a viewport.\n * @param viewport The viewport to attach this strategy to.\n */\n attach(viewport: CdkVirtualScrollViewport) {\n this._viewport = viewport;\n this._updateTotalContentSize();\n this._updateRenderedRange();\n }\n\n /** Detaches this scroll strategy from the currently attached viewport. */\n detach() {\n this._scrolledIndexChange.complete();\n this._viewport = null;\n }\n\n /**\n * Update the item size and buffer size.\n * @param itemDynamicSize The size of the items in the virtually scrolling list.\n * @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more\n * @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.\n * @param isReverse\n */\n updateItemAndBufferSize(itemDynamicSize: itemDynamicSize[], minBufferPx: number, maxBufferPx: number, isReverse: boolean) {\n if (maxBufferPx < minBufferPx) {\n throw Error('CDK virtual scroll: maxBufferPx must be greater than or equal to minBufferPx');\n }\n this._itemDynamicSize = itemDynamicSize;\n this._minBufferPx = minBufferPx;\n this._maxBufferPx = maxBufferPx;\n this._isReverse = isReverse;\n this._updateTotalContentSize();\n this._updateRenderedRange();\n }\n\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n onContentScrolled() {\n this._updateRenderedRange();\n }\n\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n onDataLengthChanged() {\n this._updateTotalContentSize();\n this._updateRenderedRange();\n }\n\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n onContentRendered() {\n /* no-op */\n }\n\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n onRenderedOffsetChanged() {\n /* no-op */\n }\n\n /**\n * Scroll to the offset for the given index.\n * @param index The index of the element to scroll to.\n * @param behavior The ScrollBehavior to use when scrolling.\n */\n scrollToIndex(index: number, behavior: ScrollBehavior): void {\n if (this._viewport) {\n const size = sumItemSize(this._itemDynamicSize, index);\n this._viewport.scrollToOffset(size, behavior);\n }\n }\n\n /** Update the viewport's total content size. */\n private _updateTotalContentSize() {\n if (!this._viewport) {\n return;\n }\n\n const size = sumItemSize(this._itemDynamicSize, this._viewport.getDataLength());\n this._viewport.setTotalContentSize(size);\n }\n\n /** Update the viewport's rendered range. */\n private _updateRenderedRange() {\n if (!this._viewport) {\n return;\n }\n if (this._viewport.getViewportSize() === 0) {\n // DOM is not ready yet. We should check again once the viewport is visible.\n requestAnimationFrame(() => this._viewport?.checkViewportSize());\n return;\n }\n\n const renderedRange = this._viewport.getRenderedRange();\n const newRange = { start: renderedRange.start, end: renderedRange.end };\n const viewportSize = this._viewport.getViewportSize();\n const dataLength = this._viewport.getDataLength();\n\n // Reverse offset if _isReverse\n let scrollOffset = !this._isReverse\n ? this._viewport.measureScrollOffset()\n : Math.max(0, this._viewport.getElementRef().nativeElement.scrollTop * -1);\n\n // let firstVisibleIndex = this._itemDynamicSize > 0 ? scrollOffset / this._itemDynamicSize : 0;\n let firstVisibleIndex = this._itemDynamicSize.length > 0 ? Math.floor(calcIndex(this._itemDynamicSize, scrollOffset)) : 0;\n\n // If user scrolls to the bottom of the list and data changes to a smaller list\n if (newRange.end > dataLength) {\n // We have to recalculate the first visible index based on new data length and viewport size.\n const maxVisibleItems = Math.ceil(calcIndex(this._itemDynamicSize, viewportSize));\n const newVisibleIndex = Math.max(0, Math.min(firstVisibleIndex, dataLength - maxVisibleItems));\n\n // If first visible index changed we must update scroll offset to handle start/end buffers\n // Current range must also be adjusted to cover the new position (bottom of new list).\n if (firstVisibleIndex != newVisibleIndex) {\n firstVisibleIndex = newVisibleIndex;\n // scrollOffset = newVisibleIndex * this._itemDynamicSize;\n scrollOffset = sumItemSize(this._itemDynamicSize, newVisibleIndex);\n newRange.start = Math.floor(firstVisibleIndex);\n }\n\n newRange.end = Math.max(0, Math.min(dataLength, newRange.start + maxVisibleItems));\n }\n\n // const startBuffer = scrollOffset - newRange.start * this._itemDynamicSize;\n const startBuffer = scrollOffset - sumItemSize(this._itemDynamicSize, newRange.start);\n if (startBuffer < this._minBufferPx && newRange.start != 0) {\n // const expandStart = Math.ceil((this._maxBufferPx - startBuffer) / this._itemDynamicSize);\n const expandStart = Math.ceil(calcIndex(this._itemDynamicSize, this._maxBufferPx - startBuffer, newRange.start, true));\n newRange.start = Math.max(0, newRange.start - expandStart);\n // newRange.end = Math.min(dataLength, Math.ceil(firstVisibleIndex + (viewportSize + this._minBufferPx) / this._itemDynamicSize));\n newRange.end = Math.min(\n dataLength,\n Math.ceil(firstVisibleIndex + calcIndex(this._itemDynamicSize, viewportSize + this._minBufferPx, firstVisibleIndex)) + 1, // firstVisibleIndexを削った影響\n );\n\n // console.log(\n // 'expandStart',\n // firstVisibleIndex,\n // '\"' + newRange.start + '-' + newRange.end + '\"',\n // dataLength,\n // viewportSize + this._minBufferPx,\n // Math.ceil(firstVisibleIndex + calcIndex(this._itemDynamicSize, viewportSize + this._minBufferPx, firstVisibleIndex)),\n // );\n } else {\n // const endBuffer = newRange.end * this._itemSize - (scrollOffset + viewportSize);\n const endBuffer = Math.max(sumItemSize(this._itemDynamicSize, newRange.end) - (scrollOffset + viewportSize), 0);\n if (endBuffer < this._minBufferPx && newRange.end != dataLength) {\n // const expandEnd = Math.ceil((this._maxBufferPx - endBuffer) / this._itemDynamicSize);\n const expandEnd = Math.ceil(calcIndex(this._itemDynamicSize, this._maxBufferPx - endBuffer, newRange.end));\n\n if (expandEnd > 0) {\n newRange.end = Math.min(dataLength, newRange.end + expandEnd);\n // Math.floor(firstVisibleIndex - this._minBufferPx / this._itemSize),\n newRange.start = Math.max(\n 0,\n Math.floor(firstVisibleIndex - calcIndex(this._itemDynamicSize, this._minBufferPx, firstVisibleIndex, true)),\n );\n // console.log(\n // 'expandEnd',\n // firstVisibleIndex,\n // '\"' + newRange.start + '-' + newRange.end + '\"',\n // dataLength,\n // Math.ceil(firstVisibleIndex + calcIndex(this._itemDynamicSize, viewportSize + this._minBufferPx, firstVisibleIndex)),\n // );\n }\n }\n }\n\n if (newRange.start === 0 && newRange.end === 0 && dataLength > 0) {\n // Have items but not rendered yet.\n // This can happen when itemDynamicSizes is still empty while dataLength is already available.\n // Use the same policy as the initial render in fixed-size virtual scroll: viewport + maxBuffer.\n if (this._itemDynamicSize.length === 0) {\n newRange.end = Math.min(dataLength, 1);\n } else {\n const initialEnd = Math.ceil(calcIndex(this._itemDynamicSize, viewportSize + this._maxBufferPx, 0)) + 1;\n newRange.end = Math.min(dataLength, Math.max(1, initialEnd));\n }\n }\n\n if (firstVisibleIndex === 0 && newRange.start > firstVisibleIndex) {\n // This is bug fix. If newRange.start > firstVisibleIndex, can't visible '0'\n newRange.start = firstVisibleIndex;\n }\n\n if (newRange.start > newRange.end) {\n // This is bug fix. If newRange.start > newRange.end, it will cause infinite loop.\n newRange.end = Math.min(\n dataLength,\n Math.ceil(newRange.start + calcIndex(this._itemDynamicSize, viewportSize + this._minBufferPx, newRange.start)),\n );\n }\n\n this._viewport.setRenderedRange(newRange);\n // this._viewport.setRenderedContentOffset(this._itemDynamicSize * newRange.start);\n if (!this._isReverse) {\n this._viewport.setRenderedContentOffset(sumItemSize(this._itemDynamicSize, newRange.start));\n } else {\n let offset = Math.min(0, sumItemSize(this._itemDynamicSize, newRange.start) * -1);\n if (offset === 0) {\n offset = 0;\n }\n this._viewport.setRenderedContentOffset(offset);\n }\n this.measureScrollOffset = scrollOffset;\n this._latestDataLength = dataLength;\n this._scrolledIndexChange.next(firstVisibleIndex);\n }\n}\n\n/**\n * Provider factory for `FixedSizeVirtualScrollStrategy` that simply extracts the already created\n * `FixedSizeVirtualScrollStrategy` from the given directive.\n * @param fixedSizeDir The instance of `CdkFixedSizeVirtualScroll` to extract the\n * `FixedSizeVirtualScrollStrategy` from.\n */\nexport function _dynamicSizeVirtualScrollStrategyFactory(fixedSizeDir: CdkDynamicSizeVirtualScroll) {\n return fixedSizeDir._scrollStrategy;\n}\n\nexport type itemDynamicSize = { itemSize: number } & Record<string, string | number>;\n\nexport const sumItemSize = (dynamicSize: itemDynamicSize[], endIndex: number): number => {\n return dynamicSize.slice(0, endIndex).reduce((acc, item) => acc + item.itemSize, 0);\n};\n\n/**\n * TODO: 計算方法の見直し\n * 0.5 = 0個目の半分はマイナスの計算が生まれるため、1個目からカウント\n */\nexport const calcIndex = (dynamicSize: itemDynamicSize[], itemSizeRange: number, startIndex = 0, isReverse = false): number => {\n let sum = 0;\n let diffIndex = 0;\n const item = isReverse ? structuredClone(dynamicSize).reverse() : dynamicSize;\n if (isReverse) {\n startIndex = dynamicSize.length - startIndex;\n }\n const calcIndex = item.reduce((acc, currentValue, index) => {\n if (index < startIndex) {\n return acc;\n }\n if (acc !== -1) {\n // 既に見つかった場合、何もしない\n return acc;\n }\n sum += currentValue.itemSize;\n if (sum >= itemSizeRange) {\n if (sum === itemSizeRange) {\n return index - startIndex;\n }\n\n const diff = sum - itemSizeRange;\n const getOver = item[index].itemSize - diff;\n diffIndex = getOver / item[index].itemSize;\n return Math.max(0, index - 1 + diffIndex - startIndex);\n } else if (index === item.length - 1) {\n return index - startIndex + 1;\n }\n return acc;\n }, -1);\n return calcIndex === -1 ? 0 : calcIndex;\n};\n\n/** A virtual scroll strategy that supports fixed-size items. */\n@Directive({\n selector: 'cdk-virtual-scroll-viewport[itemDynamicSizes]',\n providers: [\n {\n provide: VIRTUAL_SCROLL_STRATEGY,\n useFactory: _dynamicSizeVirtualScrollStrategyFactory,\n deps: [forwardRef(() => CdkDynamicSizeVirtualScroll)],\n },\n ],\n})\nexport class CdkDynamicSizeVirtualScroll {\n private readonly el = inject(ElementRef);\n\n readonly itemDynamicSizes = input<itemDynamicSize[], itemDynamicSize[]>([], {\n transform: coerceArray,\n });\n\n /**\n * The minimum amount of buffer rendered beyond the viewport (in pixels).\n * If the amount of buffer dips below this number, more items will be rendered. Defaults to 100px.\n */\n readonly minBufferPx = input<number, NumberInput>(100, {\n transform: coerceNumberProperty,\n });\n\n /**\n * The number of pixels worth of buffer to render for when rendering new items. Defaults to 200px.\n */\n readonly maxBufferPx = input<number, NumberInput>(200, {\n transform: coerceNumberProperty,\n });\n\n readonly isReverse = input<boolean, BooleanInput>(false, {\n transform: coerceBooleanProperty,\n });\n\n /** The scroll strategy used by this directive. */\n readonly _scrollStrategy = new DynamicSizeVirtualScrollStrategy(\n this.itemDynamicSizes(),\n this.minBufferPx(),\n this.maxBufferPx(),\n this.isReverse(),\n );\n\n constructor() {\n effect(() => {\n if (this.isReverse()) {\n this.el.nativeElement.classList.add('reverse-scroll');\n } else {\n this.el.nativeElement.classList.remove('reverse-scroll');\n }\n });\n effect(() =>\n this._scrollStrategy.updateItemAndBufferSize(this.itemDynamicSizes(), this.minBufferPx(), this.maxBufferPx(), this.isReverse()),\n );\n }\n\n /** For isReverse scroll. Because virtualScroll.measureScrollOffset is not work. **/\n get scrollOffset(): number {\n return this._scrollStrategy.measureScrollOffset;\n }\n}\n","/*\n * Public API Surface of dynamic-size-virtual-scroll\n */\n\nexport * from './lib/dynamic-size-virtual-scroll.service';\nexport * from './lib/dynamic-size-virtual-scroll-strategy';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MAOa,+BAA+B,CAAA;AAH5C,IAAA,WAAA,GAAA;QAIW,IAAA,CAAA,YAAY,GAAG,GAAG;AAmH5B,IAAA;AAjHC;;;;AAIG;IACH,MAAM,CAAC,aAAuC,EAAE,kBAA0B,EAAA;AACxE,QAAA,IAAI,kBAAkB,GAAG,CAAC,EAAE;AAC1B,YAAA,aAAa,CAAC,cAAc,CAAC,kBAAkB,CAAC;QAClD;IACF;AAEA;;AAEG;AACH,IAAA,SAAS,CAAC,aAAuC,EAAA;AAC/C,QAAA,OAAO,aAAa,CAAC,mBAAmB,CAAC,KAAK,CAAC;IACjD;AAEA;;;AAGG;AACH,IAAA,wBAAwB,CAAC,oBAA+C,EAAA;QACtE,OAAO,QAAQ,CAAW,MAAK;YAC7B,OAAO,oBAAoB,EAAE,CAAC,GAAG,CAAC,CAAC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A,EAR3B;AACT,YAAA;AACE,gBAAA,OAAO,EAAE,uBAAuB;AAChC,gBAAA,UAAU,EAAE,wCAAwC;gBACpD,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,2BAA2B,CAAC,CAAC;AACtD,aAAA;AACF,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAEU,2BAA2B,EAAA,UAAA,EAAA,CAAA;kBAVvC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,+CAA+C;AACzD,oBAAA,SAAS,EAAE;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,uBAAuB;AAChC,4BAAA,UAAU,EAAE,wCAAwC;4BACpD,IAAI,EAAE,CAAC,UAAU,CAAC,MAAK,2BAA4B,CAAC,CAAC;AACtD,yBAAA;AACF,qBAAA;AACF,iBAAA;;;AChUD;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"rdlabo-ngx-cdk-scroll-strategies.mjs","sources":["../../../projects/scroll-strategies/src/lib/dynamic-size-virtual-scroll.service.ts","../../../projects/scroll-strategies/src/lib/dynamic-size-virtual-scroll.util.ts","../../../projects/scroll-strategies/src/lib/dynamic-size-virtual-scroll-strategy.ts","../../../projects/scroll-strategies/src/public-api.ts","../../../projects/scroll-strategies/src/rdlabo-ngx-cdk-scroll-strategies.ts"],"sourcesContent":["import { computed, Injectable, Signal } from '@angular/core';\nimport { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';\nimport { itemDynamicSize } from './dynamic-size-virtual-scroll.util';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class DynamicSizeVirtualScrollService {\n readonly mergeScrollY = 160;\n\n /*\n * iOS smooth scroll can scroll after transition end.\n * In this case, sometimes Virtual Scroll is white screen.\n * Scroll amount restoration prevents this.\n */\n onInit(virtualScroll: CdkVirtualScrollViewport, latestScrollOffset: number) {\n if (latestScrollOffset > 0) {\n virtualScroll.scrollToOffset(latestScrollOffset);\n }\n }\n\n /**\n * Save scroll amount for next view enter.\n */\n onDestroy(virtualScroll: CdkVirtualScrollViewport): number {\n return virtualScroll.measureScrollOffset('top');\n }\n\n /**\n * Change itemDynamicSize[] to style.height[].\n * require itemDynamicSize has 'source' and 'itemSize'.\n */\n getBindDynamicItemHeight($calcDynamicItemSize: Signal<itemDynamicSize[]>): Signal<string[]> {\n return computed<string[]>(() => {\n return $calcDynamicItemSize().map((item) => {\n return item['source'] === 'temporary' ? 'auto' : item.itemSize + 'px';\n });\n });\n }\n\n /**\n * If change the array of hidden areas during scrolling,\n * a layout shift will occur. (If not reverse, refers to the array located above the display area.)\n * This function confirms that it is OK to change the array.\n */\n isEnableMerge(virtualScroll: CdkVirtualScrollViewport): boolean {\n return virtualScroll.getRenderedRange().start === 0 && virtualScroll.measureScrollOffset('top') < this.mergeScrollY;\n }\n\n /**\n * When an array is destructively replaced,\n * the height of the viewport may remain the same as the sum of the previous array.\n * This force it to be initialized.\n */\n refreshViewport(virtualScroll: CdkVirtualScrollViewport): void {\n virtualScroll.scrollToOffset(0);\n virtualScroll.setRenderedContentOffset(0);\n virtualScroll.setRenderedRange({ start: 0, end: 0 });\n }\n\n /**\n * This is for smooth scrolling to the top.\n */\n async scrollToTopSmooth(virtualScroll: CdkVirtualScrollViewport): Promise<void> {\n await this.scrollToPoint(virtualScroll, 0, 0, 400);\n }\n\n /**\n * This is for smooth scrolling to a specific point.\n * https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/content/content.tsx#L357C3-L404C4\n */\n async scrollToPoint(\n el: CdkVirtualScrollViewport,\n x: number | undefined | null,\n y: number | undefined | null,\n duration = 0,\n ): Promise<void> {\n if (duration < 32) {\n if (y != null) {\n el.scrollToOffset(y);\n }\n if (x != null) {\n el.scrollToOffset(x);\n }\n return;\n }\n\n let resolve!: () => void;\n let startTime = 0;\n const promise = new Promise<void>((r) => (resolve = r));\n const fromY = el.measureScrollOffset('top');\n const fromX = el.measureScrollOffset('left');\n\n const deltaY = y != null ? y - fromY : 0;\n const deltaX = x != null ? x - fromX : 0;\n\n // scroll loop\n const step = (timeStamp: number) => {\n const linearTime = Math.min(1, (timeStamp - startTime) / duration) - 1;\n const easedT = Math.pow(linearTime, 3) + 1;\n\n if (deltaY !== 0) {\n el.scrollToOffset(Math.floor(easedT * deltaY + fromY));\n }\n if (deltaX !== 0) {\n el.scrollToOffset(Math.floor(easedT * deltaX + fromX));\n }\n\n if (easedT < 1) {\n // do not use DomController here\n // must use nativeRaf in order to fire in the next frame\n requestAnimationFrame(step);\n } else {\n resolve();\n }\n };\n // chill out for a frame first\n requestAnimationFrame((ts) => {\n startTime = ts;\n step(ts);\n });\n return promise;\n }\n}\n","/** Describes the exact pixel size of an item and any consumer-defined tracking metadata. */\nexport type itemDynamicSize = { itemSize: number } & Record<string, string | number>;\n\n/** Returns the cumulative size of all items before `endIndex`. */\nexport const sumItemSize = (dynamicSize: itemDynamicSize[], endIndex: number): number => {\n return dynamicSize.slice(0, endIndex).reduce((acc, item) => acc + item.itemSize, 0);\n};\n\n/**\n * Retains the package's legacy pixel-to-index calculation for compatibility.\n * @deprecated Use `calculateItemCountForPixelDistance` for mathematically continuous results.\n */\nexport const calcIndex = (dynamicSize: itemDynamicSize[], itemSizeRange: number, startIndex = 0, isReverse = false): number => {\n let sum = 0;\n let diffIndex = 0;\n const item = isReverse ? [...dynamicSize].reverse() : dynamicSize;\n if (isReverse) {\n startIndex = dynamicSize.length - startIndex;\n }\n const calculatedIndex = item.reduce((acc, currentValue, index) => {\n if (index < startIndex || acc !== -1) {\n return acc;\n }\n sum += currentValue.itemSize;\n if (sum >= itemSizeRange) {\n if (sum === itemSizeRange) {\n return index - startIndex;\n }\n const diff = sum - itemSizeRange;\n const getOver = item[index].itemSize - diff;\n diffIndex = getOver / item[index].itemSize;\n return Math.max(0, index - 1 + diffIndex - startIndex);\n }\n if (index === item.length - 1) {\n return index - startIndex + 1;\n }\n return acc;\n }, -1);\n return calculatedIndex === -1 ? 0 : calculatedIndex;\n};\n\n/**\n * Converts a pixel distance into an exact fractional item count.\n *\n * Forward measurement starts at `startIndex`. Reverse measurement starts immediately before\n * `startIndex`, matching the items that precede a rendered range. The result is bounded by the\n * number of available items in that direction.\n */\nexport const calculateItemCountForPixelDistance = (\n dynamicSize: itemDynamicSize[],\n itemSizeRange: number,\n startIndex = 0,\n isReverse = false,\n): number => {\n let remaining = Math.max(0, itemSizeRange);\n let count = 0;\n let index = isReverse ? Math.min(dynamicSize.length, Math.max(0, Math.trunc(startIndex))) - 1 : Math.max(0, Math.trunc(startIndex));\n const step = isReverse ? -1 : 1;\n\n while (index >= 0 && index < dynamicSize.length && remaining > 0) {\n const size = dynamicSize[index].itemSize;\n if (remaining < size) {\n return count + remaining / size;\n }\n remaining -= size;\n count += 1;\n index += step;\n }\n\n return count;\n};\n\n/** Builds cumulative item boundaries from zero through `length`. */\nexport const createPrefixSums = (dynamicSize: itemDynamicSize[], length: number): number[] => {\n const prefixSums = new Array<number>(length + 1);\n prefixSums[0] = 0;\n for (let index = 0; index < length; index += 1) {\n prefixSums[index + 1] = prefixSums[index] + dynamicSize[index].itemSize;\n }\n return prefixSums;\n};\n\nconst lowerBound = (values: number[], target: number): number => {\n let low = 0;\n let high = values.length;\n while (low < high) {\n const middle = low + Math.floor((high - low) / 2);\n if (values[middle] < target) {\n low = middle + 1;\n } else {\n high = middle;\n }\n }\n return low;\n};\n\nconst upperBound = (values: number[], target: number): number => {\n let low = 0;\n let high = values.length;\n while (low < high) {\n const middle = low + Math.floor((high - low) / 2);\n if (values[middle] <= target) {\n low = middle + 1;\n } else {\n high = middle;\n }\n }\n return low;\n};\n\n/** Returns the item containing `offset`, choosing the next item at an exact boundary. */\nexport const indexAtOffset = (prefixSums: number[], offset: number): number => {\n const itemCount = prefixSums.length - 1;\n return Math.min(itemCount - 1, Math.max(0, upperBound(prefixSums, offset) - 1));\n};\n\n/** Returns the earliest rendered index whose boundary supplies the requested start buffer. */\nexport const startIndexForOffset = (prefixSums: number[], offset: number): number => {\n const itemCount = prefixSums.length - 1;\n return Math.min(itemCount - 1, Math.max(0, upperBound(prefixSums, offset) - 1));\n};\n\n/** Returns the exclusive rendered end index whose boundary covers `offset`. */\nexport const endIndexForOffset = (prefixSums: number[], offset: number): number => {\n return Math.min(prefixSums.length - 1, Math.max(1, lowerBound(prefixSums, offset)));\n};\n\n/** Mutates a rendered range so it covers the viewport plus equal start and end buffers. */\nexport const setRangeForBuffer = (\n range: { start: number; end: number },\n prefixSums: number[],\n scrollOffset: number,\n viewportSize: number,\n bufferPx: number,\n): void => {\n range.start = startIndexForOffset(prefixSums, scrollOffset - bufferPx);\n range.end = endIndexForOffset(prefixSums, scrollOffset + viewportSize + bufferPx);\n};\n\n/** Validates item sizes and virtual scroll buffer configuration. */\nexport const validateConfiguration = (dynamicSize: itemDynamicSize[], minBufferPx: number, maxBufferPx: number): void => {\n if (!Number.isFinite(minBufferPx) || minBufferPx < 0 || !Number.isFinite(maxBufferPx) || maxBufferPx < minBufferPx) {\n throw Error('CDK virtual scroll: buffers must be finite, non-negative, and maxBufferPx must be greater than or equal to minBufferPx');\n }\n dynamicSize.forEach(({ itemSize }, index) => {\n if (!Number.isFinite(itemSize) || itemSize <= 0) {\n throw Error(`CDK virtual scroll: item size at index ${index} must be a finite number greater than zero`);\n }\n });\n};\n","/**\n *\n * https://github.com/angular/components/blob/main/src/cdk/scrolling/fixed-size-virtual-scroll.ts\n */\n\nimport { BooleanInput, coerceArray, coerceBooleanProperty, coerceNumberProperty, NumberInput } from '@angular/cdk/coercion';\nimport { Directive, effect, ElementRef, forwardRef, inject, input } from '@angular/core';\nimport { Observable, Subject } from 'rxjs';\nimport { distinctUntilChanged } from 'rxjs/operators';\nimport { CdkVirtualScrollViewport, VIRTUAL_SCROLL_STRATEGY, VirtualScrollStrategy } from '@angular/cdk/scrolling';\nimport {\n createPrefixSums,\n endIndexForOffset,\n indexAtOffset,\n itemDynamicSize,\n setRangeForBuffer,\n startIndexForOffset,\n validateConfiguration,\n} from './dynamic-size-virtual-scroll.util';\n\n/** Virtual scrolling strategy for lists whose item sizes are known in advance. */\nexport class DynamicSizeVirtualScrollStrategy implements VirtualScrollStrategy {\n private readonly _scrolledIndexChange = new Subject<number>();\n\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n scrolledIndexChange: Observable<number> = this._scrolledIndexChange.pipe(distinctUntilChanged());\n\n /** The attached viewport. */\n private _viewport: CdkVirtualScrollViewport | null = null;\n\n /** The size of the items in the virtually scrolling list. */\n private _itemDynamicSize: itemDynamicSize[];\n\n /** Cumulative item boundaries. Rebuilt only when the size model or data length changes. */\n private _prefixSums: number[] = [0];\n private _prefixDataLength = -1;\n\n /** The minimum amount of buffer rendered beyond the viewport (in pixels). */\n private _minBufferPx: number;\n\n /** The number of buffer items to render beyond the edge of the viewport (in pixels). */\n private _maxBufferPx: number;\n\n /** This is added for reverse virtual scroll **/\n private _isReverse: boolean;\n\n /** Last normalized scroll offset, exposed because CDK cannot measure the reverse layout. */\n measureScrollOffset = 0;\n\n /**\n * @param itemSize The size of the items in the virtually scrolling list.\n * @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more\n * @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.\n * @param isReverse Added from rdlabo for reverse\n */\n constructor(itemSize: itemDynamicSize[], minBufferPx: number, maxBufferPx: number, isReverse: boolean) {\n validateConfiguration(itemSize, minBufferPx, maxBufferPx);\n this._itemDynamicSize = itemSize;\n this._minBufferPx = minBufferPx;\n this._maxBufferPx = maxBufferPx;\n this._isReverse = isReverse;\n }\n\n /**\n * Attaches this scroll strategy to a viewport.\n * @param viewport The viewport to attach this strategy to.\n */\n attach(viewport: CdkVirtualScrollViewport) {\n this._viewport = viewport;\n this._updateTotalContentSize();\n this._updateRenderedRange();\n }\n\n /** Detaches this scroll strategy from the currently attached viewport. */\n detach() {\n this._scrolledIndexChange.complete();\n this._viewport = null;\n }\n\n /**\n * Update the item size and buffer size.\n * @param itemDynamicSize The size of the items in the virtually scrolling list.\n * @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more\n * @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.\n * @param isReverse\n */\n updateItemAndBufferSize(itemDynamicSize: itemDynamicSize[], minBufferPx: number, maxBufferPx: number, isReverse: boolean) {\n validateConfiguration(itemDynamicSize, minBufferPx, maxBufferPx);\n this._itemDynamicSize = itemDynamicSize;\n this._prefixDataLength = -1;\n this._minBufferPx = minBufferPx;\n this._maxBufferPx = maxBufferPx;\n this._isReverse = isReverse;\n this._updateTotalContentSize();\n this._updateRenderedRange();\n }\n\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n onContentScrolled() {\n this._updateRenderedRange();\n }\n\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n onDataLengthChanged() {\n this._updateTotalContentSize();\n this._updateRenderedRange();\n }\n\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n onContentRendered() {\n /* no-op */\n }\n\n /** @docs-private Implemented as part of VirtualScrollStrategy. */\n onRenderedOffsetChanged() {\n /* no-op */\n }\n\n /**\n * Scroll to the offset for the given index.\n * @param index The index of the element to scroll to.\n * @param behavior The ScrollBehavior to use when scrolling.\n */\n scrollToIndex(index: number, behavior: ScrollBehavior): void {\n if (this._viewport) {\n if (!this._hasCompleteSizeModel(this._viewport.getDataLength())) {\n return;\n }\n const prefixSums = this._getPrefixSums(this._viewport.getDataLength());\n const boundedIndex = Math.min(prefixSums.length - 1, Math.max(0, Math.trunc(index)));\n const offset = prefixSums[boundedIndex];\n this._viewport.scrollToOffset(this._isReverse ? -offset : offset, behavior);\n }\n }\n\n /** Update the viewport's total content size. */\n private _updateTotalContentSize() {\n if (!this._viewport) {\n return;\n }\n\n const dataLength = this._viewport.getDataLength();\n if (dataLength === 0) {\n this._viewport.setTotalContentSize(0);\n return;\n }\n if (!this._hasCompleteSizeModel(dataLength)) {\n return;\n }\n\n const prefixSums = this._getPrefixSums(dataLength);\n this._viewport.setTotalContentSize(prefixSums[prefixSums.length - 1]);\n }\n\n /** Update the viewport's rendered range. */\n private _updateRenderedRange() {\n if (!this._viewport) {\n return;\n }\n if (this._viewport.getViewportSize() === 0) {\n // DOM is not ready yet. We should check again once the viewport is visible.\n requestAnimationFrame(() => this._viewport?.checkViewportSize());\n return;\n }\n\n const renderedRange = this._viewport.getRenderedRange();\n const newRange = { start: renderedRange.start, end: renderedRange.end };\n const viewportSize = this._viewport.getViewportSize();\n const dataLength = this._viewport.getDataLength();\n\n if (dataLength === 0) {\n this._viewport.setRenderedRange({ start: 0, end: 0 });\n this._viewport.setRenderedContentOffset(0);\n this.measureScrollOffset = 0;\n this._scrolledIndexChange.next(0);\n return;\n }\n\n // Angular can update cdkVirtualForOf and itemDynamicSizes in separate turns. A partial size\n // model cannot define an exact total height or offset, so retain the last complete geometry\n // until both lengths agree. On first attachment, render one item so a measuring consumer can\n // obtain its initial size.\n if (!this._hasCompleteSizeModel(dataLength)) {\n if (newRange.start === 0 && newRange.end === 0) {\n this._viewport.setRenderedRange({ start: 0, end: 1 });\n this._viewport.setRenderedContentOffset(0);\n }\n return;\n }\n\n const prefixSums = this._getPrefixSums(dataLength);\n const totalContentSize = prefixSums[dataLength];\n\n // Reverse offset if _isReverse\n const measuredScrollOffset = !this._isReverse\n ? this._viewport.measureScrollOffset()\n : Math.max(0, this._viewport.getElementRef().nativeElement.scrollTop * -1);\n // The browser clamps the actual offset to this interval. Applying the same clamp immediately\n // also makes a data-length shrink deterministic before the next native scroll event.\n const scrollOffset = Math.min(Math.max(0, measuredScrollOffset), Math.max(0, totalContentSize - viewportSize));\n const firstVisibleIndex = indexAtOffset(prefixSums, scrollOffset);\n\n const rangeIsInvalid = newRange.start < 0 || newRange.start >= newRange.end || newRange.end > dataLength;\n if (rangeIsInvalid) {\n setRangeForBuffer(newRange, prefixSums, scrollOffset, viewportSize, this._maxBufferPx);\n } else {\n const startBuffer = scrollOffset - prefixSums[newRange.start];\n const endBuffer = prefixSums[newRange.end] - (scrollOffset + viewportSize);\n\n if (startBuffer < this._minBufferPx && newRange.start > 0) {\n newRange.start = startIndexForOffset(prefixSums, scrollOffset - this._maxBufferPx);\n newRange.end = endIndexForOffset(prefixSums, scrollOffset + viewportSize + this._minBufferPx);\n } else if (endBuffer < this._minBufferPx && newRange.end < dataLength) {\n newRange.end = endIndexForOffset(prefixSums, scrollOffset + viewportSize + this._maxBufferPx);\n newRange.start = startIndexForOffset(prefixSums, scrollOffset - this._minBufferPx);\n }\n }\n\n this._viewport.setRenderedRange(newRange);\n if (!this._isReverse) {\n this._viewport.setRenderedContentOffset(prefixSums[newRange.start]);\n } else {\n let offset = Math.min(0, prefixSums[newRange.start] * -1);\n if (offset === 0) {\n offset = 0;\n }\n this._viewport.setRenderedContentOffset(offset);\n }\n this.measureScrollOffset = scrollOffset;\n this._scrolledIndexChange.next(firstVisibleIndex);\n }\n\n private _getPrefixSums(dataLength: number): number[] {\n const modeledLength = dataLength;\n if (modeledLength !== this._prefixDataLength) {\n this._prefixSums = createPrefixSums(this._itemDynamicSize, modeledLength);\n this._prefixDataLength = modeledLength;\n }\n return this._prefixSums;\n }\n\n private _hasCompleteSizeModel(dataLength: number): boolean {\n return this._itemDynamicSize.length === dataLength;\n }\n}\n\n/**\n * Provider factory for `FixedSizeVirtualScrollStrategy` that simply extracts the already created\n * `FixedSizeVirtualScrollStrategy` from the given directive.\n * @param fixedSizeDir The instance of `CdkFixedSizeVirtualScroll` to extract the\n * `FixedSizeVirtualScrollStrategy` from.\n */\nexport function _dynamicSizeVirtualScrollStrategyFactory(fixedSizeDir: CdkDynamicSizeVirtualScroll) {\n return fixedSizeDir._scrollStrategy;\n}\n\n/** Directive that installs dynamic-size virtual scrolling on a CDK viewport. */\n@Directive({\n selector: 'cdk-virtual-scroll-viewport[itemDynamicSizes]',\n providers: [\n {\n provide: VIRTUAL_SCROLL_STRATEGY,\n useFactory: _dynamicSizeVirtualScrollStrategyFactory,\n deps: [forwardRef(() => CdkDynamicSizeVirtualScroll)],\n },\n ],\n})\nexport class CdkDynamicSizeVirtualScroll {\n private readonly el = inject(ElementRef);\n\n readonly itemDynamicSizes = input<itemDynamicSize[], itemDynamicSize[]>([], {\n transform: coerceArray,\n });\n\n /**\n * The minimum amount of buffer rendered beyond the viewport (in pixels).\n * If the amount of buffer dips below this number, more items will be rendered. Defaults to 100px.\n */\n readonly minBufferPx = input<number, NumberInput>(100, {\n transform: coerceNumberProperty,\n });\n\n /**\n * The number of pixels worth of buffer to render for when rendering new items. Defaults to 200px.\n */\n readonly maxBufferPx = input<number, NumberInput>(200, {\n transform: coerceNumberProperty,\n });\n\n readonly isReverse = input<boolean, BooleanInput>(false, {\n transform: coerceBooleanProperty,\n });\n\n /** The scroll strategy used by this directive. */\n readonly _scrollStrategy = new DynamicSizeVirtualScrollStrategy(\n this.itemDynamicSizes(),\n this.minBufferPx(),\n this.maxBufferPx(),\n this.isReverse(),\n );\n\n constructor() {\n effect(() => {\n if (this.isReverse()) {\n this.el.nativeElement.classList.add('reverse-scroll');\n } else {\n this.el.nativeElement.classList.remove('reverse-scroll');\n }\n });\n effect(() =>\n this._scrollStrategy.updateItemAndBufferSize(this.itemDynamicSizes(), this.minBufferPx(), this.maxBufferPx(), this.isReverse()),\n );\n }\n\n /** For isReverse scroll. Because virtualScroll.measureScrollOffset is not work. **/\n get scrollOffset(): number {\n return this._scrollStrategy.measureScrollOffset;\n }\n}\n","/*\n * Public API Surface of dynamic-size-virtual-scroll\n */\n\nexport * from './lib/dynamic-size-virtual-scroll.service';\nexport * from './lib/dynamic-size-virtual-scroll-strategy';\nexport { calcIndex, calculateItemCountForPixelDistance, sumItemSize, type itemDynamicSize } from './lib/dynamic-size-virtual-scroll.util';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;MAOa,+BAA+B,CAAA;AAH5C,IAAA,WAAA,GAAA;QAIW,IAAA,CAAA,YAAY,GAAG,GAAG;AAmH5B,IAAA;AAjHC;;;;AAIG;IACH,MAAM,CAAC,aAAu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iBAAA,EAAA,aAAA,EAAA,UAAA,EAAA,aAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,WAAA,EAAA,EAAA,iBAAA,EAAA,aAAA,EAAA,UAAA,EAAA,aAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,SAAA,EAAA,EAAA,iBAAA,EAAA,WAAA,EAAA,UAAA,EAAA,WAAA,EAAA,QAAA,EAAA,IAAA,EAAA,UAAA,EAAA,KAAA,EAAA,iBAAA,EAAA,IAAA,EAAA,EAAA,EAAA,SAAA,EAR3B;AACT,YAAA;AACE,gBAAA,OAAO,EAAE,uBAAuB;AAChC,gBAAA,UAAU,EAAE,wCAAwC;gBACpD,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,2BAA2B,CAAC,CAAC;AACtD,aAAA;AACF,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,CAAA,CAAA;;4FAEU,2BAA2B,EAAA,UAAA,EAAA,CAAA;kBAVvC,SAAS;AAAC,YAAA,IAAA,EAAA,CAAA;AACT,oBAAA,QAAQ,EAAE,+CAA+C;AACzD,oBAAA,SAAS,EAAE;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,uBAAuB;AAChC,4BAAA,UAAU,EAAE,wCAAwC;4BACpD,IAAI,EAAE,CAAC,UAAU,CAAC,MAAK,2BAA4B,CAAC,CAAC;AACtD,yBAAA;AACF,qBAAA;AACF,iBAAA;;;AC1QD;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,67 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
2
|
import { Signal } from '@angular/core';
|
|
3
|
-
import {
|
|
3
|
+
import { CdkVirtualScrollViewport, VirtualScrollStrategy } from '@angular/cdk/scrolling';
|
|
4
4
|
import { NumberInput, BooleanInput } from '@angular/cdk/coercion';
|
|
5
5
|
import { Observable } from 'rxjs';
|
|
6
6
|
|
|
7
|
-
/**
|
|
7
|
+
/** Describes the exact pixel size of an item and any consumer-defined tracking metadata. */
|
|
8
|
+
type itemDynamicSize = {
|
|
9
|
+
itemSize: number;
|
|
10
|
+
} & Record<string, string | number>;
|
|
11
|
+
/** Returns the cumulative size of all items before `endIndex`. */
|
|
12
|
+
declare const sumItemSize: (dynamicSize: itemDynamicSize[], endIndex: number) => number;
|
|
13
|
+
/**
|
|
14
|
+
* Retains the package's legacy pixel-to-index calculation for compatibility.
|
|
15
|
+
* @deprecated Use `calculateItemCountForPixelDistance` for mathematically continuous results.
|
|
16
|
+
*/
|
|
17
|
+
declare const calcIndex: (dynamicSize: itemDynamicSize[], itemSizeRange: number, startIndex?: number, isReverse?: boolean) => number;
|
|
18
|
+
/**
|
|
19
|
+
* Converts a pixel distance into an exact fractional item count.
|
|
20
|
+
*
|
|
21
|
+
* Forward measurement starts at `startIndex`. Reverse measurement starts immediately before
|
|
22
|
+
* `startIndex`, matching the items that precede a rendered range. The result is bounded by the
|
|
23
|
+
* number of available items in that direction.
|
|
24
|
+
*/
|
|
25
|
+
declare const calculateItemCountForPixelDistance: (dynamicSize: itemDynamicSize[], itemSizeRange: number, startIndex?: number, isReverse?: boolean) => number;
|
|
26
|
+
|
|
27
|
+
declare class DynamicSizeVirtualScrollService {
|
|
28
|
+
readonly mergeScrollY = 160;
|
|
29
|
+
onInit(virtualScroll: CdkVirtualScrollViewport, latestScrollOffset: number): void;
|
|
30
|
+
/**
|
|
31
|
+
* Save scroll amount for next view enter.
|
|
32
|
+
*/
|
|
33
|
+
onDestroy(virtualScroll: CdkVirtualScrollViewport): number;
|
|
34
|
+
/**
|
|
35
|
+
* Change itemDynamicSize[] to style.height[].
|
|
36
|
+
* require itemDynamicSize has 'source' and 'itemSize'.
|
|
37
|
+
*/
|
|
38
|
+
getBindDynamicItemHeight($calcDynamicItemSize: Signal<itemDynamicSize[]>): Signal<string[]>;
|
|
39
|
+
/**
|
|
40
|
+
* If change the array of hidden areas during scrolling,
|
|
41
|
+
* a layout shift will occur. (If not reverse, refers to the array located above the display area.)
|
|
42
|
+
* This function confirms that it is OK to change the array.
|
|
43
|
+
*/
|
|
44
|
+
isEnableMerge(virtualScroll: CdkVirtualScrollViewport): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* When an array is destructively replaced,
|
|
47
|
+
* the height of the viewport may remain the same as the sum of the previous array.
|
|
48
|
+
* This force it to be initialized.
|
|
49
|
+
*/
|
|
50
|
+
refreshViewport(virtualScroll: CdkVirtualScrollViewport): void;
|
|
51
|
+
/**
|
|
52
|
+
* This is for smooth scrolling to the top.
|
|
53
|
+
*/
|
|
54
|
+
scrollToTopSmooth(virtualScroll: CdkVirtualScrollViewport): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* This is for smooth scrolling to a specific point.
|
|
57
|
+
* https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/content/content.tsx#L357C3-L404C4
|
|
58
|
+
*/
|
|
59
|
+
scrollToPoint(el: CdkVirtualScrollViewport, x: number | undefined | null, y: number | undefined | null, duration?: number): Promise<void>;
|
|
60
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<DynamicSizeVirtualScrollService, never>;
|
|
61
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<DynamicSizeVirtualScrollService>;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Virtual scrolling strategy for lists whose item sizes are known in advance. */
|
|
8
65
|
declare class DynamicSizeVirtualScrollStrategy implements VirtualScrollStrategy {
|
|
9
66
|
private readonly _scrolledIndexChange;
|
|
10
67
|
/** @docs-private Implemented as part of VirtualScrollStrategy. */
|
|
@@ -13,15 +70,17 @@ declare class DynamicSizeVirtualScrollStrategy implements VirtualScrollStrategy
|
|
|
13
70
|
private _viewport;
|
|
14
71
|
/** The size of the items in the virtually scrolling list. */
|
|
15
72
|
private _itemDynamicSize;
|
|
73
|
+
/** Cumulative item boundaries. Rebuilt only when the size model or data length changes. */
|
|
74
|
+
private _prefixSums;
|
|
75
|
+
private _prefixDataLength;
|
|
16
76
|
/** The minimum amount of buffer rendered beyond the viewport (in pixels). */
|
|
17
77
|
private _minBufferPx;
|
|
18
78
|
/** The number of buffer items to render beyond the edge of the viewport (in pixels). */
|
|
19
79
|
private _maxBufferPx;
|
|
20
80
|
/** This is added for reverse virtual scroll **/
|
|
21
81
|
private _isReverse;
|
|
82
|
+
/** Last normalized scroll offset, exposed because CDK cannot measure the reverse layout. */
|
|
22
83
|
measureScrollOffset: number;
|
|
23
|
-
/** This is added for change dataLength **/
|
|
24
|
-
private _latestDataLength;
|
|
25
84
|
/**
|
|
26
85
|
* @param itemSize The size of the items in the virtually scrolling list.
|
|
27
86
|
* @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more
|
|
@@ -62,6 +121,8 @@ declare class DynamicSizeVirtualScrollStrategy implements VirtualScrollStrategy
|
|
|
62
121
|
private _updateTotalContentSize;
|
|
63
122
|
/** Update the viewport's rendered range. */
|
|
64
123
|
private _updateRenderedRange;
|
|
124
|
+
private _getPrefixSums;
|
|
125
|
+
private _hasCompleteSizeModel;
|
|
65
126
|
}
|
|
66
127
|
/**
|
|
67
128
|
* Provider factory for `FixedSizeVirtualScrollStrategy` that simply extracts the already created
|
|
@@ -70,16 +131,7 @@ declare class DynamicSizeVirtualScrollStrategy implements VirtualScrollStrategy
|
|
|
70
131
|
* `FixedSizeVirtualScrollStrategy` from.
|
|
71
132
|
*/
|
|
72
133
|
declare function _dynamicSizeVirtualScrollStrategyFactory(fixedSizeDir: CdkDynamicSizeVirtualScroll): DynamicSizeVirtualScrollStrategy;
|
|
73
|
-
|
|
74
|
-
itemSize: number;
|
|
75
|
-
} & Record<string, string | number>;
|
|
76
|
-
declare const sumItemSize: (dynamicSize: itemDynamicSize[], endIndex: number) => number;
|
|
77
|
-
/**
|
|
78
|
-
* TODO: 計算方法の見直し
|
|
79
|
-
* 0.5 = 0個目の半分はマイナスの計算が生まれるため、1個目からカウント
|
|
80
|
-
*/
|
|
81
|
-
declare const calcIndex: (dynamicSize: itemDynamicSize[], itemSizeRange: number, startIndex?: number, isReverse?: boolean) => number;
|
|
82
|
-
/** A virtual scroll strategy that supports fixed-size items. */
|
|
134
|
+
/** Directive that installs dynamic-size virtual scrolling on a CDK viewport. */
|
|
83
135
|
declare class CdkDynamicSizeVirtualScroll {
|
|
84
136
|
private readonly el;
|
|
85
137
|
readonly itemDynamicSizes: _angular_core.InputSignalWithTransform<itemDynamicSize[], itemDynamicSize[]>;
|
|
@@ -102,42 +154,5 @@ declare class CdkDynamicSizeVirtualScroll {
|
|
|
102
154
|
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<CdkDynamicSizeVirtualScroll, "cdk-virtual-scroll-viewport[itemDynamicSizes]", never, { "itemDynamicSizes": { "alias": "itemDynamicSizes"; "required": false; "isSignal": true; }; "minBufferPx": { "alias": "minBufferPx"; "required": false; "isSignal": true; }; "maxBufferPx": { "alias": "maxBufferPx"; "required": false; "isSignal": true; }; "isReverse": { "alias": "isReverse"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
103
155
|
}
|
|
104
156
|
|
|
105
|
-
|
|
106
|
-
readonly mergeScrollY = 160;
|
|
107
|
-
onInit(virtualScroll: CdkVirtualScrollViewport, latestScrollOffset: number): void;
|
|
108
|
-
/**
|
|
109
|
-
* Save scroll amount for next view enter.
|
|
110
|
-
*/
|
|
111
|
-
onDestroy(virtualScroll: CdkVirtualScrollViewport): number;
|
|
112
|
-
/**
|
|
113
|
-
* Change itemDynamicSize[] to style.height[].
|
|
114
|
-
* require itemDynamicSize has 'source' and 'itemSize'.
|
|
115
|
-
*/
|
|
116
|
-
getBindDynamicItemHeight($calcDynamicItemSize: Signal<itemDynamicSize[]>): Signal<string[]>;
|
|
117
|
-
/**
|
|
118
|
-
* If change the array of hidden areas during scrolling,
|
|
119
|
-
* a layout shift will occur. (If not reverse, refers to the array located above the display area.)
|
|
120
|
-
* This function confirms that it is OK to change the array.
|
|
121
|
-
*/
|
|
122
|
-
isEnableMerge(virtualScroll: CdkVirtualScrollViewport): boolean;
|
|
123
|
-
/**
|
|
124
|
-
* When an array is destructively replaced,
|
|
125
|
-
* the height of the viewport may remain the same as the sum of the previous array.
|
|
126
|
-
* This force it to be initialized.
|
|
127
|
-
*/
|
|
128
|
-
refreshViewport(virtualScroll: CdkVirtualScrollViewport): void;
|
|
129
|
-
/**
|
|
130
|
-
* This is for smooth scrolling to the top.
|
|
131
|
-
*/
|
|
132
|
-
scrollToTopSmooth(virtualScroll: CdkVirtualScrollViewport): Promise<void>;
|
|
133
|
-
/**
|
|
134
|
-
* This is for smooth scrolling to a specific point.
|
|
135
|
-
* https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/content/content.tsx#L357C3-L404C4
|
|
136
|
-
*/
|
|
137
|
-
scrollToPoint(el: CdkVirtualScrollViewport, x: number | undefined | null, y: number | undefined | null, duration?: number): Promise<void>;
|
|
138
|
-
static ɵfac: _angular_core.ɵɵFactoryDeclaration<DynamicSizeVirtualScrollService, never>;
|
|
139
|
-
static ɵprov: _angular_core.ɵɵInjectableDeclaration<DynamicSizeVirtualScrollService>;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export { CdkDynamicSizeVirtualScroll, DynamicSizeVirtualScrollService, DynamicSizeVirtualScrollStrategy, _dynamicSizeVirtualScrollStrategyFactory, calcIndex, sumItemSize };
|
|
157
|
+
export { CdkDynamicSizeVirtualScroll, DynamicSizeVirtualScrollService, DynamicSizeVirtualScrollStrategy, _dynamicSizeVirtualScrollStrategyFactory, calcIndex, calculateItemCountForPixelDistance, sumItemSize };
|
|
143
158
|
export type { itemDynamicSize };
|