@rdlabo/ngx-cdk-scroll-strategies 0.0.1 → 0.0.2
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 +2 -2
- package/esm2022/lib/dynamic-size-virtual-scroll-strategy.mjs +335 -0
- package/esm2022/lib/dynamic-size-virtual-scroll.service.mjs +86 -0
- package/esm2022/public-api.mjs +6 -0
- package/esm2022/rdlabo-ngx-cdk-scroll-strategies.mjs +5 -0
- package/fesm2022/rdlabo-ngx-cdk-scroll-strategies.mjs +430 -0
- package/fesm2022/rdlabo-ngx-cdk-scroll-strategies.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/lib/dynamic-size-virtual-scroll-strategy.d.ts +112 -0
- package/lib/dynamic-size-virtual-scroll.service.d.ts +17 -0
- package/package.json +16 -3
- package/{src/public-api.ts → public-api.d.ts} +0 -4
- package/ng-package.json +0 -7
- package/src/lib/dynamic-size-virtual-scroll-strategy.spec.ts +0 -385
- package/src/lib/dynamic-size-virtual-scroll-strategy.ts +0 -378
- package/src/lib/dynamic-size-virtual-scroll.service.spec.ts +0 -16
- package/src/lib/dynamic-size-virtual-scroll.service.ts +0 -98
- package/tsconfig.lib.json +0 -14
- package/tsconfig.lib.prod.json +0 -10
- package/tsconfig.spec.json +0 -14
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { computed, Injectable, forwardRef, Directive, Input } from '@angular/core';
|
|
3
|
+
import { coerceNumberProperty } from '@angular/cdk/coercion';
|
|
4
|
+
import { Subject } from 'rxjs';
|
|
5
|
+
import { distinctUntilChanged } from 'rxjs/operators';
|
|
6
|
+
import { VIRTUAL_SCROLL_STRATEGY } from '@angular/cdk/scrolling';
|
|
7
|
+
|
|
8
|
+
class DynamicSizeVirtualScrollService {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.mergeScrollY = 160;
|
|
11
|
+
}
|
|
12
|
+
onInit(virtualScroll, latestScrollOffset) {
|
|
13
|
+
if (latestScrollOffset > 0) {
|
|
14
|
+
virtualScroll.scrollToOffset(latestScrollOffset);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
onDestroy(virtualScroll) {
|
|
18
|
+
return virtualScroll.measureScrollOffset('top');
|
|
19
|
+
}
|
|
20
|
+
getBindDynamicItemHeight($calcDynamicItemSize) {
|
|
21
|
+
return computed(() => {
|
|
22
|
+
return $calcDynamicItemSize().map((item) => {
|
|
23
|
+
return item['source'] === 'temporary' ? 'auto' : item.itemSize + 'px';
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
async scrollToTopSmooth(virtualScroll) {
|
|
28
|
+
await this.scrollToPoint(virtualScroll, 0, 0, 400);
|
|
29
|
+
}
|
|
30
|
+
isEnableMerge(virtualScroll) {
|
|
31
|
+
return virtualScroll.getRenderedRange().start === 0 && virtualScroll.measureScrollOffset('top') < this.mergeScrollY;
|
|
32
|
+
}
|
|
33
|
+
refreshViewport(virtualScroll) {
|
|
34
|
+
virtualScroll.scrollToOffset(0);
|
|
35
|
+
virtualScroll.setRenderedContentOffset(0);
|
|
36
|
+
virtualScroll.setRenderedRange({ start: 0, end: 0 });
|
|
37
|
+
}
|
|
38
|
+
// https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/content/content.tsx#L357C3-L404C4
|
|
39
|
+
async scrollToPoint(el, x, y, duration = 0) {
|
|
40
|
+
if (duration < 32) {
|
|
41
|
+
if (y != null) {
|
|
42
|
+
el.scrollToOffset(y);
|
|
43
|
+
}
|
|
44
|
+
if (x != null) {
|
|
45
|
+
el.scrollToOffset(x);
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
let resolve;
|
|
50
|
+
let startTime = 0;
|
|
51
|
+
const promise = new Promise((r) => (resolve = r));
|
|
52
|
+
const fromY = el.measureScrollOffset('top');
|
|
53
|
+
const fromX = el.measureScrollOffset('left');
|
|
54
|
+
const deltaY = y != null ? y - fromY : 0;
|
|
55
|
+
const deltaX = x != null ? x - fromX : 0;
|
|
56
|
+
// scroll loop
|
|
57
|
+
const step = (timeStamp) => {
|
|
58
|
+
const linearTime = Math.min(1, (timeStamp - startTime) / duration) - 1;
|
|
59
|
+
const easedT = Math.pow(linearTime, 3) + 1;
|
|
60
|
+
if (deltaY !== 0) {
|
|
61
|
+
el.scrollToOffset(Math.floor(easedT * deltaY + fromY));
|
|
62
|
+
}
|
|
63
|
+
if (deltaX !== 0) {
|
|
64
|
+
el.scrollToOffset(Math.floor(easedT * deltaX + fromX));
|
|
65
|
+
}
|
|
66
|
+
if (easedT < 1) {
|
|
67
|
+
// do not use DomController here
|
|
68
|
+
// must use nativeRaf in order to fire in the next frame
|
|
69
|
+
requestAnimationFrame(step);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
resolve();
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
// chill out for a frame first
|
|
76
|
+
requestAnimationFrame((ts) => {
|
|
77
|
+
startTime = ts;
|
|
78
|
+
step(ts);
|
|
79
|
+
});
|
|
80
|
+
return promise;
|
|
81
|
+
}
|
|
82
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.4", ngImport: i0, type: DynamicSizeVirtualScrollService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
83
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "18.0.4", ngImport: i0, type: DynamicSizeVirtualScrollService, providedIn: 'root' }); }
|
|
84
|
+
}
|
|
85
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.4", ngImport: i0, type: DynamicSizeVirtualScrollService, decorators: [{
|
|
86
|
+
type: Injectable,
|
|
87
|
+
args: [{
|
|
88
|
+
providedIn: 'root',
|
|
89
|
+
}]
|
|
90
|
+
}], ctorParameters: () => [] });
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
*
|
|
94
|
+
* https://github.com/angular/components/blob/main/src/cdk/scrolling/fixed-size-virtual-scroll.ts
|
|
95
|
+
*/
|
|
96
|
+
/* eslint-disable @rdlabo/rules/deny-soft-private-modifier */
|
|
97
|
+
/* eslint-disable @angular-eslint/directive-selector */
|
|
98
|
+
/* eslint-disable @angular-eslint/directive-class-suffix */
|
|
99
|
+
/** Virtual scrolling strategy for lists with items of known fixed size. */
|
|
100
|
+
class DynamicSizeVirtualScrollStrategy {
|
|
101
|
+
/**
|
|
102
|
+
* @param itemSize The size of the items in the virtually scrolling list.
|
|
103
|
+
* @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more
|
|
104
|
+
* @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.
|
|
105
|
+
* @param isReverse Added from rdlabo for reverse
|
|
106
|
+
*/
|
|
107
|
+
constructor(itemSize, minBufferPx, maxBufferPx, isReverse) {
|
|
108
|
+
this._scrolledIndexChange = new Subject();
|
|
109
|
+
/** @docs-private Implemented as part of VirtualScrollStrategy. */
|
|
110
|
+
this.scrolledIndexChange = this._scrolledIndexChange.pipe(distinctUntilChanged());
|
|
111
|
+
/** The attached viewport. */
|
|
112
|
+
this._viewport = null;
|
|
113
|
+
this.measureScrollOffset = 0;
|
|
114
|
+
this._itemDynamicSize = itemSize;
|
|
115
|
+
this._minBufferPx = minBufferPx;
|
|
116
|
+
this._maxBufferPx = maxBufferPx;
|
|
117
|
+
this._isReverse = isReverse;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Attaches this scroll strategy to a viewport.
|
|
121
|
+
* @param viewport The viewport to attach this strategy to.
|
|
122
|
+
*/
|
|
123
|
+
attach(viewport) {
|
|
124
|
+
this._viewport = viewport;
|
|
125
|
+
this._updateTotalContentSize();
|
|
126
|
+
this._updateRenderedRange();
|
|
127
|
+
}
|
|
128
|
+
/** Detaches this scroll strategy from the currently attached viewport. */
|
|
129
|
+
detach() {
|
|
130
|
+
this._scrolledIndexChange.complete();
|
|
131
|
+
this._viewport = null;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Update the item size and buffer size.
|
|
135
|
+
* @param itemDynamicSize The size of the items in the virtually scrolling list.
|
|
136
|
+
* @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more
|
|
137
|
+
* @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.
|
|
138
|
+
* @param isReverse
|
|
139
|
+
*/
|
|
140
|
+
updateItemAndBufferSize(itemDynamicSize, minBufferPx, maxBufferPx, isReverse) {
|
|
141
|
+
// if (maxBufferPx < minBufferPx && (typeof ngDevMode === 'undefined' || ngDevMode)) {
|
|
142
|
+
if (maxBufferPx < minBufferPx) {
|
|
143
|
+
throw Error('CDK virtual scroll: maxBufferPx must be greater than or equal to minBufferPx');
|
|
144
|
+
}
|
|
145
|
+
this._itemDynamicSize = itemDynamicSize;
|
|
146
|
+
this._minBufferPx = minBufferPx;
|
|
147
|
+
this._maxBufferPx = maxBufferPx;
|
|
148
|
+
this._isReverse = isReverse;
|
|
149
|
+
this._updateTotalContentSize();
|
|
150
|
+
this._updateRenderedRange();
|
|
151
|
+
}
|
|
152
|
+
/** @docs-private Implemented as part of VirtualScrollStrategy. */
|
|
153
|
+
onContentScrolled() {
|
|
154
|
+
this._updateRenderedRange();
|
|
155
|
+
}
|
|
156
|
+
/** @docs-private Implemented as part of VirtualScrollStrategy. */
|
|
157
|
+
onDataLengthChanged() {
|
|
158
|
+
this._updateTotalContentSize();
|
|
159
|
+
this._updateRenderedRange();
|
|
160
|
+
}
|
|
161
|
+
/** @docs-private Implemented as part of VirtualScrollStrategy. */
|
|
162
|
+
onContentRendered() {
|
|
163
|
+
/* no-op */
|
|
164
|
+
}
|
|
165
|
+
/** @docs-private Implemented as part of VirtualScrollStrategy. */
|
|
166
|
+
onRenderedOffsetChanged() {
|
|
167
|
+
/* no-op */
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Scroll to the offset for the given index.
|
|
171
|
+
* @param index The index of the element to scroll to.
|
|
172
|
+
* @param behavior The ScrollBehavior to use when scrolling.
|
|
173
|
+
*/
|
|
174
|
+
scrollToIndex(index, behavior) {
|
|
175
|
+
if (this._viewport) {
|
|
176
|
+
const size = sumItemSize(this._itemDynamicSize, index);
|
|
177
|
+
this._viewport.scrollToOffset(size, behavior);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/** Update the viewport's total content size. */
|
|
181
|
+
_updateTotalContentSize() {
|
|
182
|
+
if (!this._viewport) {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const size = sumItemSize(this._itemDynamicSize, this._viewport.getDataLength());
|
|
186
|
+
this._viewport.setTotalContentSize(size);
|
|
187
|
+
}
|
|
188
|
+
/** Update the viewport's rendered range. */
|
|
189
|
+
_updateRenderedRange() {
|
|
190
|
+
if (!this._viewport) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (this._viewport.getViewportSize() === 0) {
|
|
194
|
+
// DOM is not ready yet. We should check again once the viewport is visible.
|
|
195
|
+
requestAnimationFrame(() => this._viewport?.checkViewportSize());
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const renderedRange = this._viewport.getRenderedRange();
|
|
199
|
+
const newRange = { start: renderedRange.start, end: renderedRange.end };
|
|
200
|
+
const viewportSize = this._viewport.getViewportSize();
|
|
201
|
+
const dataLength = this._viewport.getDataLength();
|
|
202
|
+
// Reverse offset if _isReverse
|
|
203
|
+
let scrollOffset = !this._isReverse
|
|
204
|
+
? this._viewport.measureScrollOffset()
|
|
205
|
+
: Math.max(0, this._viewport.getElementRef().nativeElement.scrollTop * -1);
|
|
206
|
+
// let firstVisibleIndex = this._itemDynamicSize > 0 ? scrollOffset / this._itemDynamicSize : 0;
|
|
207
|
+
let firstVisibleIndex = this._itemDynamicSize.length > 0 ? Math.floor(calcIndex(this._itemDynamicSize, scrollOffset)) : 0;
|
|
208
|
+
// If user scrolls to the bottom of the list and data changes to a smaller list
|
|
209
|
+
if (newRange.end > dataLength) {
|
|
210
|
+
// We have to recalculate the first visible index based on new data length and viewport size.
|
|
211
|
+
const maxVisibleItems = Math.ceil(calcIndex(this._itemDynamicSize, viewportSize));
|
|
212
|
+
const newVisibleIndex = Math.max(0, Math.min(firstVisibleIndex, dataLength - maxVisibleItems));
|
|
213
|
+
// If first visible index changed we must update scroll offset to handle start/end buffers
|
|
214
|
+
// Current range must also be adjusted to cover the new position (bottom of new list).
|
|
215
|
+
if (firstVisibleIndex != newVisibleIndex) {
|
|
216
|
+
firstVisibleIndex = newVisibleIndex;
|
|
217
|
+
// scrollOffset = newVisibleIndex * this._itemDynamicSize;
|
|
218
|
+
scrollOffset = sumItemSize(this._itemDynamicSize, newVisibleIndex);
|
|
219
|
+
newRange.start = Math.floor(firstVisibleIndex);
|
|
220
|
+
}
|
|
221
|
+
newRange.end = Math.max(0, Math.min(dataLength, newRange.start + maxVisibleItems));
|
|
222
|
+
}
|
|
223
|
+
// const startBuffer = scrollOffset - newRange.start * this._itemDynamicSize;
|
|
224
|
+
const startBuffer = scrollOffset - sumItemSize(this._itemDynamicSize, newRange.start);
|
|
225
|
+
if (startBuffer < this._minBufferPx && newRange.start != 0) {
|
|
226
|
+
// const expandStart = Math.ceil((this._maxBufferPx - startBuffer) / this._itemDynamicSize);
|
|
227
|
+
const expandStart = Math.ceil(calcIndex(this._itemDynamicSize, this._maxBufferPx - startBuffer, newRange.start, true));
|
|
228
|
+
newRange.start = Math.max(0, newRange.start - expandStart);
|
|
229
|
+
// newRange.end = Math.min(dataLength, Math.ceil(firstVisibleIndex + (viewportSize + this._minBufferPx) / this._itemDynamicSize));
|
|
230
|
+
newRange.end = Math.min(dataLength, Math.ceil(firstVisibleIndex + calcIndex(this._itemDynamicSize, viewportSize + this._minBufferPx, firstVisibleIndex)) + 1);
|
|
231
|
+
// console.log(
|
|
232
|
+
// 'expandStart',
|
|
233
|
+
// firstVisibleIndex,
|
|
234
|
+
// '"' + newRange.start + '-' + newRange.end + '"',
|
|
235
|
+
// dataLength,
|
|
236
|
+
// viewportSize + this._minBufferPx,
|
|
237
|
+
// Math.ceil(firstVisibleIndex + calcIndex(this._itemDynamicSize, viewportSize + this._minBufferPx, firstVisibleIndex)),
|
|
238
|
+
// );
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
// const endBuffer = newRange.end * this._itemSize - (scrollOffset + viewportSize);
|
|
242
|
+
const endBuffer = Math.max(sumItemSize(this._itemDynamicSize, newRange.end) - (scrollOffset + viewportSize), 0);
|
|
243
|
+
if (endBuffer < this._minBufferPx && newRange.end != dataLength) {
|
|
244
|
+
// const expandEnd = Math.ceil((this._maxBufferPx - endBuffer) / this._itemDynamicSize);
|
|
245
|
+
const expandEnd = endBuffer === 0 && newRange.start < newRange.end && dataLength - 1 > newRange.end
|
|
246
|
+
? // When endBuffer is 0, but not the last item:
|
|
247
|
+
dataLength - newRange.end
|
|
248
|
+
: Math.ceil(calcIndex(this._itemDynamicSize, this._maxBufferPx - endBuffer, newRange.end));
|
|
249
|
+
if (expandEnd > 0) {
|
|
250
|
+
newRange.end = Math.min(dataLength, newRange.end + expandEnd);
|
|
251
|
+
// Math.floor(firstVisibleIndex - this._minBufferPx / this._itemSize),
|
|
252
|
+
newRange.start = Math.max(0, Math.floor(firstVisibleIndex - calcIndex(this._itemDynamicSize, this._minBufferPx, firstVisibleIndex, true)));
|
|
253
|
+
// console.log(
|
|
254
|
+
// 'expandEnd',
|
|
255
|
+
// firstVisibleIndex,
|
|
256
|
+
// '"' + newRange.start + '-' + newRange.end + '"',
|
|
257
|
+
// dataLength,
|
|
258
|
+
// Math.ceil(firstVisibleIndex + calcIndex(this._itemDynamicSize, viewportSize + this._minBufferPx, firstVisibleIndex)),
|
|
259
|
+
// );
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (newRange.start === 0 && newRange.end === 0 && dataLength > 0) {
|
|
264
|
+
// have items but not rendered, set start index to 0
|
|
265
|
+
newRange.end = dataLength;
|
|
266
|
+
}
|
|
267
|
+
if (firstVisibleIndex === 0 && newRange.start > firstVisibleIndex) {
|
|
268
|
+
// This is bug fix. If newRange.start > firstVisibleIndex, can't visible '0'
|
|
269
|
+
newRange.start = firstVisibleIndex;
|
|
270
|
+
}
|
|
271
|
+
if (newRange.start > newRange.end) {
|
|
272
|
+
// This is bug fix. If newRange.start > newRange.end, it will cause infinite loop.
|
|
273
|
+
newRange.end = Math.min(dataLength, Math.ceil(newRange.start + calcIndex(this._itemDynamicSize, viewportSize + this._minBufferPx, newRange.start)));
|
|
274
|
+
}
|
|
275
|
+
this._viewport.setRenderedRange(newRange);
|
|
276
|
+
// this._viewport.setRenderedContentOffset(this._itemDynamicSize * newRange.start);
|
|
277
|
+
if (!this._isReverse) {
|
|
278
|
+
this._viewport.setRenderedContentOffset(sumItemSize(this._itemDynamicSize, newRange.start));
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
let offset = Math.min(0, sumItemSize(this._itemDynamicSize, newRange.start) * -1);
|
|
282
|
+
if (offset === 0) {
|
|
283
|
+
offset = 0;
|
|
284
|
+
}
|
|
285
|
+
this._viewport.setRenderedContentOffset(offset);
|
|
286
|
+
}
|
|
287
|
+
this.measureScrollOffset = scrollOffset;
|
|
288
|
+
this._scrolledIndexChange.next(firstVisibleIndex);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Provider factory for `FixedSizeVirtualScrollStrategy` that simply extracts the already created
|
|
293
|
+
* `FixedSizeVirtualScrollStrategy` from the given directive.
|
|
294
|
+
* @param fixedSizeDir The instance of `CdkFixedSizeVirtualScroll` to extract the
|
|
295
|
+
* `FixedSizeVirtualScrollStrategy` from.
|
|
296
|
+
*/
|
|
297
|
+
function _dynamicSizeVirtualScrollStrategyFactory(fixedSizeDir) {
|
|
298
|
+
return fixedSizeDir._scrollStrategy;
|
|
299
|
+
}
|
|
300
|
+
const sumItemSize = (dynamicSize, endIndex) => {
|
|
301
|
+
return dynamicSize.slice(0, endIndex).reduce((acc, item) => acc + item.itemSize, 0);
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* TODO: 計算方法の見直し
|
|
305
|
+
* 0.5 = 0個目の半分はマイナスの計算が生まれるため、1個目からカウント
|
|
306
|
+
*/
|
|
307
|
+
const calcIndex = (dynamicSize, itemSizeRange, startIndex = 0, isReverse = false) => {
|
|
308
|
+
let sum = 0;
|
|
309
|
+
let diffIndex = 0;
|
|
310
|
+
const item = isReverse ? structuredClone(dynamicSize).reverse() : dynamicSize;
|
|
311
|
+
if (isReverse) {
|
|
312
|
+
startIndex = dynamicSize.length - startIndex;
|
|
313
|
+
}
|
|
314
|
+
const calcIndex = item.reduce((acc, currentValue, index) => {
|
|
315
|
+
if (index < startIndex) {
|
|
316
|
+
return acc;
|
|
317
|
+
}
|
|
318
|
+
if (acc !== -1) {
|
|
319
|
+
// 既に見つかった場合、何もしない
|
|
320
|
+
return acc;
|
|
321
|
+
}
|
|
322
|
+
sum += currentValue.itemSize;
|
|
323
|
+
if (sum >= itemSizeRange) {
|
|
324
|
+
if (sum === itemSizeRange) {
|
|
325
|
+
return index - startIndex;
|
|
326
|
+
}
|
|
327
|
+
const diff = sum - itemSizeRange;
|
|
328
|
+
const getOver = item[index].itemSize - diff;
|
|
329
|
+
diffIndex = getOver / item[index].itemSize;
|
|
330
|
+
return Math.max(0, index - 1 + diffIndex - startIndex);
|
|
331
|
+
}
|
|
332
|
+
else if (index === item.length - 1) {
|
|
333
|
+
return index - startIndex;
|
|
334
|
+
}
|
|
335
|
+
return acc;
|
|
336
|
+
}, -1);
|
|
337
|
+
return calcIndex === -1 ? 0 : calcIndex;
|
|
338
|
+
};
|
|
339
|
+
/** A virtual scroll strategy that supports fixed-size items. */
|
|
340
|
+
class CdkDynamicSizeVirtualScroll {
|
|
341
|
+
constructor() {
|
|
342
|
+
this._itemDynamicSizes = [];
|
|
343
|
+
this._minBufferPx = 100;
|
|
344
|
+
this._maxBufferPx = 200;
|
|
345
|
+
this._isReverse = false;
|
|
346
|
+
/** The scroll strategy used by this directive. */
|
|
347
|
+
this._scrollStrategy = new DynamicSizeVirtualScrollStrategy(this.itemDynamicSizes, this.minBufferPx, this.maxBufferPx, this.isReverse);
|
|
348
|
+
}
|
|
349
|
+
/** The size of the items in the list (in pixels). */
|
|
350
|
+
get itemDynamicSizes() {
|
|
351
|
+
return this._itemDynamicSizes;
|
|
352
|
+
}
|
|
353
|
+
set itemDynamicSizes(value) {
|
|
354
|
+
// coerceNumberProperty
|
|
355
|
+
this._itemDynamicSizes = value;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* The minimum amount of buffer rendered beyond the viewport (in pixels).
|
|
359
|
+
* If the amount of buffer dips below this number, more items will be rendered. Defaults to 100px.
|
|
360
|
+
*/
|
|
361
|
+
get minBufferPx() {
|
|
362
|
+
return this._minBufferPx;
|
|
363
|
+
}
|
|
364
|
+
set minBufferPx(value) {
|
|
365
|
+
this._minBufferPx = coerceNumberProperty(value);
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* The number of pixels worth of buffer to render for when rendering new items. Defaults to 200px.
|
|
369
|
+
*/
|
|
370
|
+
get maxBufferPx() {
|
|
371
|
+
return this._maxBufferPx;
|
|
372
|
+
}
|
|
373
|
+
set maxBufferPx(value) {
|
|
374
|
+
this._maxBufferPx = coerceNumberProperty(value);
|
|
375
|
+
}
|
|
376
|
+
get isReverse() {
|
|
377
|
+
return this._isReverse;
|
|
378
|
+
}
|
|
379
|
+
set isReverse(value) {
|
|
380
|
+
this._isReverse = value;
|
|
381
|
+
}
|
|
382
|
+
ngOnChanges() {
|
|
383
|
+
this._scrollStrategy.updateItemAndBufferSize(this.itemDynamicSizes, this.minBufferPx, this.maxBufferPx, this.isReverse);
|
|
384
|
+
}
|
|
385
|
+
/** For isReverse scroll. Because virtualScroll.measureScrollOffset is not work. **/
|
|
386
|
+
get scrollOffset() {
|
|
387
|
+
return this._scrollStrategy.measureScrollOffset;
|
|
388
|
+
}
|
|
389
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.0.4", ngImport: i0, type: CdkDynamicSizeVirtualScroll, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
390
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.0.4", type: CdkDynamicSizeVirtualScroll, isStandalone: true, selector: "cdk-virtual-scroll-viewport[itemDynamicSizes]", inputs: { itemDynamicSizes: "itemDynamicSizes", minBufferPx: "minBufferPx", maxBufferPx: "maxBufferPx", isReverse: "isReverse" }, providers: [
|
|
391
|
+
{
|
|
392
|
+
provide: VIRTUAL_SCROLL_STRATEGY,
|
|
393
|
+
useFactory: _dynamicSizeVirtualScrollStrategyFactory,
|
|
394
|
+
deps: [forwardRef(() => CdkDynamicSizeVirtualScroll)],
|
|
395
|
+
},
|
|
396
|
+
], usesOnChanges: true, ngImport: i0 }); }
|
|
397
|
+
}
|
|
398
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.4", ngImport: i0, type: CdkDynamicSizeVirtualScroll, decorators: [{
|
|
399
|
+
type: Directive,
|
|
400
|
+
args: [{
|
|
401
|
+
selector: 'cdk-virtual-scroll-viewport[itemDynamicSizes]',
|
|
402
|
+
standalone: true,
|
|
403
|
+
providers: [
|
|
404
|
+
{
|
|
405
|
+
provide: VIRTUAL_SCROLL_STRATEGY,
|
|
406
|
+
useFactory: _dynamicSizeVirtualScrollStrategyFactory,
|
|
407
|
+
deps: [forwardRef(() => CdkDynamicSizeVirtualScroll)],
|
|
408
|
+
},
|
|
409
|
+
],
|
|
410
|
+
}]
|
|
411
|
+
}], propDecorators: { itemDynamicSizes: [{
|
|
412
|
+
type: Input
|
|
413
|
+
}], minBufferPx: [{
|
|
414
|
+
type: Input
|
|
415
|
+
}], maxBufferPx: [{
|
|
416
|
+
type: Input
|
|
417
|
+
}], isReverse: [{
|
|
418
|
+
type: Input
|
|
419
|
+
}] } });
|
|
420
|
+
|
|
421
|
+
/*
|
|
422
|
+
* Public API Surface of dynamic-size-virtual-scroll
|
|
423
|
+
*/
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Generated bundle index. Do not edit.
|
|
427
|
+
*/
|
|
428
|
+
|
|
429
|
+
export { CdkDynamicSizeVirtualScroll, DynamicSizeVirtualScrollService, DynamicSizeVirtualScrollStrategy, _dynamicSizeVirtualScrollStrategyFactory, calcIndex, sumItemSize };
|
|
430
|
+
//# sourceMappingURL=rdlabo-ngx-cdk-scroll-strategies.mjs.map
|
|
@@ -0,0 +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 constructor() {}\n\n onInit(virtualScroll: CdkVirtualScrollViewport, latestScrollOffset: number) {\n if (latestScrollOffset > 0) {\n virtualScroll.scrollToOffset(latestScrollOffset);\n }\n }\n\n onDestroy(virtualScroll: CdkVirtualScrollViewport): number {\n return virtualScroll.measureScrollOffset('top');\n }\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 async scrollToTopSmooth(virtualScroll: CdkVirtualScrollViewport): Promise<void> {\n await this.scrollToPoint(virtualScroll, 0, 0, 400);\n }\n\n isEnableMerge(virtualScroll: CdkVirtualScrollViewport): boolean {\n return virtualScroll.getRenderedRange().start === 0 && virtualScroll.measureScrollOffset('top') < this.mergeScrollY;\n }\n\n refreshViewport(virtualScroll: CdkVirtualScrollViewport): void {\n virtualScroll.scrollToOffset(0);\n virtualScroll.setRenderedContentOffset(0);\n virtualScroll.setRenderedRange({ start: 0, end: 0 });\n }\n\n // https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/content/content.tsx#L357C3-L404C4\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\n/* eslint-disable @rdlabo/rules/deny-soft-private-modifier */\n/* eslint-disable @angular-eslint/directive-selector */\n/* eslint-disable @angular-eslint/directive-class-suffix */\n\nimport { coerceNumberProperty, NumberInput } from '@angular/cdk/coercion';\nimport { Directive, forwardRef, Input, OnChanges } 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: number = 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 && (typeof ngDevMode === 'undefined' || ngDevMode)) {\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 =\n endBuffer === 0 && newRange.start < newRange.end && dataLength - 1 > newRange.end\n ? // When endBuffer is 0, but not the last item:\n dataLength - newRange.end\n : 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, set start index to 0\n newRange.end = dataLength;\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._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;\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 standalone: true,\n providers: [\n {\n provide: VIRTUAL_SCROLL_STRATEGY,\n useFactory: _dynamicSizeVirtualScrollStrategyFactory,\n deps: [forwardRef(() => CdkDynamicSizeVirtualScroll)],\n },\n ],\n})\nexport class CdkDynamicSizeVirtualScroll implements OnChanges {\n /** The size of the items in the list (in pixels). */\n @Input()\n get itemDynamicSizes(): itemDynamicSize[] {\n return this._itemDynamicSizes;\n }\n set itemDynamicSizes(value: itemDynamicSize[]) {\n // coerceNumberProperty\n this._itemDynamicSizes = value;\n }\n _itemDynamicSizes: itemDynamicSize[] = [];\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 @Input()\n get minBufferPx(): number {\n return this._minBufferPx;\n }\n set minBufferPx(value: NumberInput) {\n this._minBufferPx = coerceNumberProperty(value);\n }\n _minBufferPx = 100;\n\n /**\n * The number of pixels worth of buffer to render for when rendering new items. Defaults to 200px.\n */\n @Input()\n get maxBufferPx(): number {\n return this._maxBufferPx;\n }\n set maxBufferPx(value: NumberInput) {\n this._maxBufferPx = coerceNumberProperty(value);\n }\n _maxBufferPx = 200;\n\n @Input()\n get isReverse(): boolean {\n return this._isReverse;\n }\n set isReverse(value: boolean) {\n this._isReverse = value;\n }\n _isReverse = false;\n\n /** The scroll strategy used by this directive. */\n _scrollStrategy = new DynamicSizeVirtualScrollStrategy(this.itemDynamicSizes, this.minBufferPx, this.maxBufferPx, this.isReverse);\n\n ngOnChanges() {\n this._scrollStrategy.updateItemAndBufferSize(this.itemDynamicSizes, this.minBufferPx, this.maxBufferPx, this.isReverse);\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;AAG1C,IAAA,WAAA,GAAA;QAFS,IAAY,CAAA,YAAA,GAAG,GAAG,CAAC;KAEZ;IAEhB,MAAM,CAAC,aAAuC,EAAE,kBAA0B,EAAA;AACxE,QAAA,IAAI,kBAAkB,GAAG,CAAC,EAAE;AAC1B,YAAA,aAAa,CAAC,cAAc,CAAC,kBAAkB,CAAC,CAAC;SAClD;KACF;AAED,IAAA,SAAS,CAAC,aAAuC,EAAA;AAC/C,QAAA,OAAO,aAAa,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;KACjD;AAED,IAAA,wBAAwB,CAAC,oBAA+C,EAAA;QACtE,OAAO,QAAQ,CAAW,MAAK;YAC7B,OAAO,oBAAoB,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,KAAI;AACzC,gBAAA,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;AACxE,aAAC,CAAC,CAAC;AACL,SAAC,CAAC,CAAC;KACJ;IAED,MAAM,iBAAiB,CAAC,aAAuC,EAAA;AAC7D,QAAA,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;KACpD;AAED,IAAA,aAAa,CAAC,aAAuC,EAAA;AACnD,QAAA,OAAO,aAAa,CAAC,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OAAO,EAAE,uBAAuB;AAChC,4BAAA,UAAU,EAAE,wCAAwC;4BACpD,IAAI,EAAE,CAAC,UAAU,CAAC,MAAK,2BAA4B,CAAC,CAAC;AACtD,yBAAA;AACF,qBAAA;AACF,iBAAA,CAAA;8BAIK,gBAAgB,EAAA,CAAA;sBADnB,KAAK;gBAeF,WAAW,EAAA,CAAA;sBADd,KAAK;gBAaF,WAAW,EAAA,CAAA;sBADd,KAAK;gBAUF,SAAS,EAAA,CAAA;sBADZ,KAAK;;;ACrWR;;AAEG;;ACFH;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* https://github.com/angular/components/blob/main/src/cdk/scrolling/fixed-size-virtual-scroll.ts
|
|
4
|
+
*/
|
|
5
|
+
import { NumberInput } from '@angular/cdk/coercion';
|
|
6
|
+
import { OnChanges } from '@angular/core';
|
|
7
|
+
import { Observable } from 'rxjs';
|
|
8
|
+
import { CdkVirtualScrollViewport, VirtualScrollStrategy } from '@angular/cdk/scrolling';
|
|
9
|
+
import * as i0 from "@angular/core";
|
|
10
|
+
/** Virtual scrolling strategy for lists with items of known fixed size. */
|
|
11
|
+
export declare class DynamicSizeVirtualScrollStrategy implements VirtualScrollStrategy {
|
|
12
|
+
private readonly _scrolledIndexChange;
|
|
13
|
+
/** @docs-private Implemented as part of VirtualScrollStrategy. */
|
|
14
|
+
scrolledIndexChange: Observable<number>;
|
|
15
|
+
/** The attached viewport. */
|
|
16
|
+
private _viewport;
|
|
17
|
+
/** The size of the items in the virtually scrolling list. */
|
|
18
|
+
private _itemDynamicSize;
|
|
19
|
+
/** The minimum amount of buffer rendered beyond the viewport (in pixels). */
|
|
20
|
+
private _minBufferPx;
|
|
21
|
+
/** The number of buffer items to render beyond the edge of the viewport (in pixels). */
|
|
22
|
+
private _maxBufferPx;
|
|
23
|
+
/** This is added for reverse virtual scroll **/
|
|
24
|
+
private _isReverse;
|
|
25
|
+
measureScrollOffset: number;
|
|
26
|
+
/**
|
|
27
|
+
* @param itemSize The size of the items in the virtually scrolling list.
|
|
28
|
+
* @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more
|
|
29
|
+
* @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.
|
|
30
|
+
* @param isReverse Added from rdlabo for reverse
|
|
31
|
+
*/
|
|
32
|
+
constructor(itemSize: itemDynamicSize[], minBufferPx: number, maxBufferPx: number, isReverse: boolean);
|
|
33
|
+
/**
|
|
34
|
+
* Attaches this scroll strategy to a viewport.
|
|
35
|
+
* @param viewport The viewport to attach this strategy to.
|
|
36
|
+
*/
|
|
37
|
+
attach(viewport: CdkVirtualScrollViewport): void;
|
|
38
|
+
/** Detaches this scroll strategy from the currently attached viewport. */
|
|
39
|
+
detach(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Update the item size and buffer size.
|
|
42
|
+
* @param itemDynamicSize The size of the items in the virtually scrolling list.
|
|
43
|
+
* @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more
|
|
44
|
+
* @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.
|
|
45
|
+
* @param isReverse
|
|
46
|
+
*/
|
|
47
|
+
updateItemAndBufferSize(itemDynamicSize: itemDynamicSize[], minBufferPx: number, maxBufferPx: number, isReverse: boolean): void;
|
|
48
|
+
/** @docs-private Implemented as part of VirtualScrollStrategy. */
|
|
49
|
+
onContentScrolled(): void;
|
|
50
|
+
/** @docs-private Implemented as part of VirtualScrollStrategy. */
|
|
51
|
+
onDataLengthChanged(): void;
|
|
52
|
+
/** @docs-private Implemented as part of VirtualScrollStrategy. */
|
|
53
|
+
onContentRendered(): void;
|
|
54
|
+
/** @docs-private Implemented as part of VirtualScrollStrategy. */
|
|
55
|
+
onRenderedOffsetChanged(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Scroll to the offset for the given index.
|
|
58
|
+
* @param index The index of the element to scroll to.
|
|
59
|
+
* @param behavior The ScrollBehavior to use when scrolling.
|
|
60
|
+
*/
|
|
61
|
+
scrollToIndex(index: number, behavior: ScrollBehavior): void;
|
|
62
|
+
/** Update the viewport's total content size. */
|
|
63
|
+
private _updateTotalContentSize;
|
|
64
|
+
/** Update the viewport's rendered range. */
|
|
65
|
+
private _updateRenderedRange;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Provider factory for `FixedSizeVirtualScrollStrategy` that simply extracts the already created
|
|
69
|
+
* `FixedSizeVirtualScrollStrategy` from the given directive.
|
|
70
|
+
* @param fixedSizeDir The instance of `CdkFixedSizeVirtualScroll` to extract the
|
|
71
|
+
* `FixedSizeVirtualScrollStrategy` from.
|
|
72
|
+
*/
|
|
73
|
+
export declare function _dynamicSizeVirtualScrollStrategyFactory(fixedSizeDir: CdkDynamicSizeVirtualScroll): DynamicSizeVirtualScrollStrategy;
|
|
74
|
+
export type itemDynamicSize = {
|
|
75
|
+
itemSize: number;
|
|
76
|
+
} & Record<string, string | number>;
|
|
77
|
+
export declare const sumItemSize: (dynamicSize: itemDynamicSize[], endIndex: number) => number;
|
|
78
|
+
/**
|
|
79
|
+
* TODO: 計算方法の見直し
|
|
80
|
+
* 0.5 = 0個目の半分はマイナスの計算が生まれるため、1個目からカウント
|
|
81
|
+
*/
|
|
82
|
+
export declare const calcIndex: (dynamicSize: itemDynamicSize[], itemSizeRange: number, startIndex?: number, isReverse?: boolean) => number;
|
|
83
|
+
/** A virtual scroll strategy that supports fixed-size items. */
|
|
84
|
+
export declare class CdkDynamicSizeVirtualScroll implements OnChanges {
|
|
85
|
+
/** The size of the items in the list (in pixels). */
|
|
86
|
+
get itemDynamicSizes(): itemDynamicSize[];
|
|
87
|
+
set itemDynamicSizes(value: itemDynamicSize[]);
|
|
88
|
+
_itemDynamicSizes: itemDynamicSize[];
|
|
89
|
+
/**
|
|
90
|
+
* The minimum amount of buffer rendered beyond the viewport (in pixels).
|
|
91
|
+
* If the amount of buffer dips below this number, more items will be rendered. Defaults to 100px.
|
|
92
|
+
*/
|
|
93
|
+
get minBufferPx(): number;
|
|
94
|
+
set minBufferPx(value: NumberInput);
|
|
95
|
+
_minBufferPx: number;
|
|
96
|
+
/**
|
|
97
|
+
* The number of pixels worth of buffer to render for when rendering new items. Defaults to 200px.
|
|
98
|
+
*/
|
|
99
|
+
get maxBufferPx(): number;
|
|
100
|
+
set maxBufferPx(value: NumberInput);
|
|
101
|
+
_maxBufferPx: number;
|
|
102
|
+
get isReverse(): boolean;
|
|
103
|
+
set isReverse(value: boolean);
|
|
104
|
+
_isReverse: boolean;
|
|
105
|
+
/** The scroll strategy used by this directive. */
|
|
106
|
+
_scrollStrategy: DynamicSizeVirtualScrollStrategy;
|
|
107
|
+
ngOnChanges(): void;
|
|
108
|
+
/** For isReverse scroll. Because virtualScroll.measureScrollOffset is not work. **/
|
|
109
|
+
get scrollOffset(): number;
|
|
110
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<CdkDynamicSizeVirtualScroll, never>;
|
|
111
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<CdkDynamicSizeVirtualScroll, "cdk-virtual-scroll-viewport[itemDynamicSizes]", never, { "itemDynamicSizes": { "alias": "itemDynamicSizes"; "required": false; }; "minBufferPx": { "alias": "minBufferPx"; "required": false; }; "maxBufferPx": { "alias": "maxBufferPx"; "required": false; }; "isReverse": { "alias": "isReverse"; "required": false; }; }, {}, never, never, true, never>;
|
|
112
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Signal } from '@angular/core';
|
|
2
|
+
import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
|
|
3
|
+
import { itemDynamicSize } from './dynamic-size-virtual-scroll-strategy';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export declare class DynamicSizeVirtualScrollService {
|
|
6
|
+
readonly mergeScrollY = 160;
|
|
7
|
+
constructor();
|
|
8
|
+
onInit(virtualScroll: CdkVirtualScrollViewport, latestScrollOffset: number): void;
|
|
9
|
+
onDestroy(virtualScroll: CdkVirtualScrollViewport): number;
|
|
10
|
+
getBindDynamicItemHeight($calcDynamicItemSize: Signal<itemDynamicSize[]>): Signal<string[]>;
|
|
11
|
+
scrollToTopSmooth(virtualScroll: CdkVirtualScrollViewport): Promise<void>;
|
|
12
|
+
isEnableMerge(virtualScroll: CdkVirtualScrollViewport): boolean;
|
|
13
|
+
refreshViewport(virtualScroll: CdkVirtualScrollViewport): void;
|
|
14
|
+
scrollToPoint(el: CdkVirtualScrollViewport, x: number | undefined | null, y: number | undefined | null, duration?: number): Promise<void>;
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DynamicSizeVirtualScrollService, never>;
|
|
16
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DynamicSizeVirtualScrollService>;
|
|
17
|
+
}
|