@rdlabo/ngx-cdk-scroll-strategies 19.0.2 → 20.0.0

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.
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { computed, Injectable, inject, ElementRef, forwardRef, Directive, Input } from '@angular/core';
2
+ import { computed, Injectable, inject, ElementRef, forwardRef, Input, Directive } from '@angular/core';
3
3
  import { coerceNumberProperty } from '@angular/cdk/coercion';
4
4
  import { Subject } from 'rxjs';
5
5
  import { distinctUntilChanged } from 'rxjs/operators';
@@ -107,10 +107,10 @@ class DynamicSizeVirtualScrollService {
107
107
  });
108
108
  return promise;
109
109
  }
110
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: DynamicSizeVirtualScrollService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
111
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: DynamicSizeVirtualScrollService, providedIn: 'root' }); }
110
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: DynamicSizeVirtualScrollService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
111
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: DynamicSizeVirtualScrollService, providedIn: 'root' }); }
112
112
  }
113
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: DynamicSizeVirtualScrollService, decorators: [{
113
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: DynamicSizeVirtualScrollService, decorators: [{
114
114
  type: Injectable,
115
115
  args: [{
116
116
  providedIn: 'root',
@@ -418,8 +418,8 @@ class CdkDynamicSizeVirtualScroll {
418
418
  get scrollOffset() {
419
419
  return this._scrollStrategy.measureScrollOffset;
420
420
  }
421
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: CdkDynamicSizeVirtualScroll, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
422
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.0.1", type: CdkDynamicSizeVirtualScroll, isStandalone: true, selector: "cdk-virtual-scroll-viewport[itemDynamicSizes]", inputs: { itemDynamicSizes: "itemDynamicSizes", minBufferPx: "minBufferPx", maxBufferPx: "maxBufferPx", isReverse: "isReverse" }, providers: [
421
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: CdkDynamicSizeVirtualScroll, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
422
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0", type: CdkDynamicSizeVirtualScroll, isStandalone: true, selector: "cdk-virtual-scroll-viewport[itemDynamicSizes]", inputs: { itemDynamicSizes: "itemDynamicSizes", minBufferPx: "minBufferPx", maxBufferPx: "maxBufferPx", isReverse: "isReverse" }, providers: [
423
423
  {
424
424
  provide: VIRTUAL_SCROLL_STRATEGY,
425
425
  useFactory: _dynamicSizeVirtualScrollStrategyFactory,
@@ -427,7 +427,7 @@ class CdkDynamicSizeVirtualScroll {
427
427
  },
428
428
  ], usesOnChanges: true, ngImport: i0 }); }
429
429
  }
430
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.1", ngImport: i0, type: CdkDynamicSizeVirtualScroll, decorators: [{
430
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0", ngImport: i0, type: CdkDynamicSizeVirtualScroll, decorators: [{
431
431
  type: Directive,
432
432
  args: [{
433
433
  selector: 'cdk-virtual-scroll-viewport[itemDynamicSizes]',
package/index.d.ts CHANGED
@@ -1,5 +1,158 @@
1
+ import * as i0 from '@angular/core';
2
+ import { OnChanges, Signal } from '@angular/core';
3
+ import { VirtualScrollStrategy, CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
4
+ import { NumberInput } from '@angular/cdk/coercion';
5
+ import { Observable } from 'rxjs';
6
+
1
7
  /**
2
- * Generated bundle index. Do not edit.
8
+ *
9
+ * https://github.com/angular/components/blob/main/src/cdk/scrolling/fixed-size-virtual-scroll.ts
3
10
  */
4
- /// <amd-module name="@rdlabo/ngx-cdk-scroll-strategies" />
5
- export * from './public-api';
11
+
12
+ /** Virtual scrolling strategy for lists with items of known fixed size. */
13
+ declare class DynamicSizeVirtualScrollStrategy implements VirtualScrollStrategy {
14
+ private readonly _scrolledIndexChange;
15
+ /** @docs-private Implemented as part of VirtualScrollStrategy. */
16
+ scrolledIndexChange: Observable<number>;
17
+ /** The attached viewport. */
18
+ private _viewport;
19
+ /** The size of the items in the virtually scrolling list. */
20
+ private _itemDynamicSize;
21
+ /** The minimum amount of buffer rendered beyond the viewport (in pixels). */
22
+ private _minBufferPx;
23
+ /** The number of buffer items to render beyond the edge of the viewport (in pixels). */
24
+ private _maxBufferPx;
25
+ /** This is added for reverse virtual scroll **/
26
+ private _isReverse;
27
+ measureScrollOffset: number;
28
+ /** This is added for change dataLength **/
29
+ private _latestDataLength;
30
+ /**
31
+ * @param itemSize The size of the items in the virtually scrolling list.
32
+ * @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more
33
+ * @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.
34
+ * @param isReverse Added from rdlabo for reverse
35
+ */
36
+ constructor(itemSize: itemDynamicSize[], minBufferPx: number, maxBufferPx: number, isReverse: boolean);
37
+ /**
38
+ * Attaches this scroll strategy to a viewport.
39
+ * @param viewport The viewport to attach this strategy to.
40
+ */
41
+ attach(viewport: CdkVirtualScrollViewport): void;
42
+ /** Detaches this scroll strategy from the currently attached viewport. */
43
+ detach(): void;
44
+ /**
45
+ * Update the item size and buffer size.
46
+ * @param itemDynamicSize The size of the items in the virtually scrolling list.
47
+ * @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more
48
+ * @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.
49
+ * @param isReverse
50
+ */
51
+ updateItemAndBufferSize(itemDynamicSize: itemDynamicSize[], minBufferPx: number, maxBufferPx: number, isReverse: boolean): void;
52
+ /** @docs-private Implemented as part of VirtualScrollStrategy. */
53
+ onContentScrolled(): void;
54
+ /** @docs-private Implemented as part of VirtualScrollStrategy. */
55
+ onDataLengthChanged(): void;
56
+ /** @docs-private Implemented as part of VirtualScrollStrategy. */
57
+ onContentRendered(): void;
58
+ /** @docs-private Implemented as part of VirtualScrollStrategy. */
59
+ onRenderedOffsetChanged(): void;
60
+ /**
61
+ * Scroll to the offset for the given index.
62
+ * @param index The index of the element to scroll to.
63
+ * @param behavior The ScrollBehavior to use when scrolling.
64
+ */
65
+ scrollToIndex(index: number, behavior: ScrollBehavior): void;
66
+ /** Update the viewport's total content size. */
67
+ private _updateTotalContentSize;
68
+ /** Update the viewport's rendered range. */
69
+ private _updateRenderedRange;
70
+ }
71
+ /**
72
+ * Provider factory for `FixedSizeVirtualScrollStrategy` that simply extracts the already created
73
+ * `FixedSizeVirtualScrollStrategy` from the given directive.
74
+ * @param fixedSizeDir The instance of `CdkFixedSizeVirtualScroll` to extract the
75
+ * `FixedSizeVirtualScrollStrategy` from.
76
+ */
77
+ declare function _dynamicSizeVirtualScrollStrategyFactory(fixedSizeDir: CdkDynamicSizeVirtualScroll): DynamicSizeVirtualScrollStrategy;
78
+ type itemDynamicSize = {
79
+ itemSize: number;
80
+ } & Record<string, string | number>;
81
+ declare const sumItemSize: (dynamicSize: itemDynamicSize[], endIndex: number) => number;
82
+ /**
83
+ * TODO: 計算方法の見直し
84
+ * 0.5 = 0個目の半分はマイナスの計算が生まれるため、1個目からカウント
85
+ */
86
+ declare const calcIndex: (dynamicSize: itemDynamicSize[], itemSizeRange: number, startIndex?: number, isReverse?: boolean) => number;
87
+ /** A virtual scroll strategy that supports fixed-size items. */
88
+ declare class CdkDynamicSizeVirtualScroll implements OnChanges {
89
+ /** The size of the items in the list (in pixels). */
90
+ get itemDynamicSizes(): itemDynamicSize[];
91
+ set itemDynamicSizes(value: itemDynamicSize[]);
92
+ _itemDynamicSizes: itemDynamicSize[];
93
+ /**
94
+ * The minimum amount of buffer rendered beyond the viewport (in pixels).
95
+ * If the amount of buffer dips below this number, more items will be rendered. Defaults to 100px.
96
+ */
97
+ get minBufferPx(): number;
98
+ set minBufferPx(value: NumberInput);
99
+ _minBufferPx: number;
100
+ /**
101
+ * The number of pixels worth of buffer to render for when rendering new items. Defaults to 200px.
102
+ */
103
+ get maxBufferPx(): number;
104
+ set maxBufferPx(value: NumberInput);
105
+ _maxBufferPx: number;
106
+ get isReverse(): boolean;
107
+ set isReverse(value: boolean);
108
+ _isReverse: boolean;
109
+ /** The scroll strategy used by this directive. */
110
+ _scrollStrategy: DynamicSizeVirtualScrollStrategy;
111
+ private el;
112
+ ngOnChanges(): void;
113
+ /** For isReverse scroll. Because virtualScroll.measureScrollOffset is not work. **/
114
+ get scrollOffset(): number;
115
+ static ɵfac: i0.ɵɵFactoryDeclaration<CdkDynamicSizeVirtualScroll, never>;
116
+ 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>;
117
+ }
118
+
119
+ declare class DynamicSizeVirtualScrollService {
120
+ readonly mergeScrollY = 160;
121
+ constructor();
122
+ onInit(virtualScroll: CdkVirtualScrollViewport, latestScrollOffset: number): void;
123
+ /**
124
+ * Save scroll amount for next view enter.
125
+ */
126
+ onDestroy(virtualScroll: CdkVirtualScrollViewport): number;
127
+ /**
128
+ * Change itemDynamicSize[] to style.height[].
129
+ * require itemDynamicSize has 'source' and 'itemSize'.
130
+ */
131
+ getBindDynamicItemHeight($calcDynamicItemSize: Signal<itemDynamicSize[]>): Signal<string[]>;
132
+ /**
133
+ * If change the array of hidden areas during scrolling,
134
+ * a layout shift will occur. (If not reverse, refers to the array located above the display area.)
135
+ * This function confirms that it is OK to change the array.
136
+ */
137
+ isEnableMerge(virtualScroll: CdkVirtualScrollViewport): boolean;
138
+ /**
139
+ * When an array is destructively replaced,
140
+ * the height of the viewport may remain the same as the sum of the previous array.
141
+ * This force it to be initialized.
142
+ */
143
+ refreshViewport(virtualScroll: CdkVirtualScrollViewport): void;
144
+ /**
145
+ * This is for smooth scrolling to the top.
146
+ */
147
+ scrollToTopSmooth(virtualScroll: CdkVirtualScrollViewport): Promise<void>;
148
+ /**
149
+ * This is for smooth scrolling to a specific point.
150
+ * https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/content/content.tsx#L357C3-L404C4
151
+ */
152
+ scrollToPoint(el: CdkVirtualScrollViewport, x: number | undefined | null, y: number | undefined | null, duration?: number): Promise<void>;
153
+ static ɵfac: i0.ɵɵFactoryDeclaration<DynamicSizeVirtualScrollService, never>;
154
+ static ɵprov: i0.ɵɵInjectableDeclaration<DynamicSizeVirtualScrollService>;
155
+ }
156
+
157
+ export { CdkDynamicSizeVirtualScroll, DynamicSizeVirtualScrollService, DynamicSizeVirtualScrollStrategy, _dynamicSizeVirtualScrollStrategyFactory, calcIndex, sumItemSize };
158
+ export type { itemDynamicSize };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@rdlabo/ngx-cdk-scroll-strategies",
3
- "version": "19.0.2",
3
+ "version": "20.0.0",
4
4
  "peerDependencies": {
5
- "@angular/cdk": "^19.0.0",
6
- "@angular/common": "^19.0.0",
7
- "@angular/core": "^19.0.0"
5
+ "@angular/cdk": "^20.0.0",
6
+ "@angular/common": "^20.0.0",
7
+ "@angular/core": "^20.0.0"
8
8
  },
9
9
  "dependencies": {
10
10
  "tslib": "^2.3.0"
@@ -1,115 +0,0 @@
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
- /** This is added for change dataLength **/
27
- private _latestDataLength;
28
- /**
29
- * @param itemSize The size of the items in the virtually scrolling list.
30
- * @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more
31
- * @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.
32
- * @param isReverse Added from rdlabo for reverse
33
- */
34
- constructor(itemSize: itemDynamicSize[], minBufferPx: number, maxBufferPx: number, isReverse: boolean);
35
- /**
36
- * Attaches this scroll strategy to a viewport.
37
- * @param viewport The viewport to attach this strategy to.
38
- */
39
- attach(viewport: CdkVirtualScrollViewport): void;
40
- /** Detaches this scroll strategy from the currently attached viewport. */
41
- detach(): void;
42
- /**
43
- * Update the item size and buffer size.
44
- * @param itemDynamicSize The size of the items in the virtually scrolling list.
45
- * @param minBufferPx The minimum amount of buffer (in pixels) before needing to render more
46
- * @param maxBufferPx The amount of buffer (in pixels) to render when rendering more.
47
- * @param isReverse
48
- */
49
- updateItemAndBufferSize(itemDynamicSize: itemDynamicSize[], minBufferPx: number, maxBufferPx: number, isReverse: boolean): void;
50
- /** @docs-private Implemented as part of VirtualScrollStrategy. */
51
- onContentScrolled(): void;
52
- /** @docs-private Implemented as part of VirtualScrollStrategy. */
53
- onDataLengthChanged(): void;
54
- /** @docs-private Implemented as part of VirtualScrollStrategy. */
55
- onContentRendered(): void;
56
- /** @docs-private Implemented as part of VirtualScrollStrategy. */
57
- onRenderedOffsetChanged(): void;
58
- /**
59
- * Scroll to the offset for the given index.
60
- * @param index The index of the element to scroll to.
61
- * @param behavior The ScrollBehavior to use when scrolling.
62
- */
63
- scrollToIndex(index: number, behavior: ScrollBehavior): void;
64
- /** Update the viewport's total content size. */
65
- private _updateTotalContentSize;
66
- /** Update the viewport's rendered range. */
67
- private _updateRenderedRange;
68
- }
69
- /**
70
- * Provider factory for `FixedSizeVirtualScrollStrategy` that simply extracts the already created
71
- * `FixedSizeVirtualScrollStrategy` from the given directive.
72
- * @param fixedSizeDir The instance of `CdkFixedSizeVirtualScroll` to extract the
73
- * `FixedSizeVirtualScrollStrategy` from.
74
- */
75
- export declare function _dynamicSizeVirtualScrollStrategyFactory(fixedSizeDir: CdkDynamicSizeVirtualScroll): DynamicSizeVirtualScrollStrategy;
76
- export type itemDynamicSize = {
77
- itemSize: number;
78
- } & Record<string, string | number>;
79
- export declare const sumItemSize: (dynamicSize: itemDynamicSize[], endIndex: number) => number;
80
- /**
81
- * TODO: 計算方法の見直し
82
- * 0.5 = 0個目の半分はマイナスの計算が生まれるため、1個目からカウント
83
- */
84
- export declare const calcIndex: (dynamicSize: itemDynamicSize[], itemSizeRange: number, startIndex?: number, isReverse?: boolean) => number;
85
- /** A virtual scroll strategy that supports fixed-size items. */
86
- export declare class CdkDynamicSizeVirtualScroll implements OnChanges {
87
- /** The size of the items in the list (in pixels). */
88
- get itemDynamicSizes(): itemDynamicSize[];
89
- set itemDynamicSizes(value: itemDynamicSize[]);
90
- _itemDynamicSizes: itemDynamicSize[];
91
- /**
92
- * The minimum amount of buffer rendered beyond the viewport (in pixels).
93
- * If the amount of buffer dips below this number, more items will be rendered. Defaults to 100px.
94
- */
95
- get minBufferPx(): number;
96
- set minBufferPx(value: NumberInput);
97
- _minBufferPx: number;
98
- /**
99
- * The number of pixels worth of buffer to render for when rendering new items. Defaults to 200px.
100
- */
101
- get maxBufferPx(): number;
102
- set maxBufferPx(value: NumberInput);
103
- _maxBufferPx: number;
104
- get isReverse(): boolean;
105
- set isReverse(value: boolean);
106
- _isReverse: boolean;
107
- /** The scroll strategy used by this directive. */
108
- _scrollStrategy: DynamicSizeVirtualScrollStrategy;
109
- private el;
110
- ngOnChanges(): void;
111
- /** For isReverse scroll. Because virtualScroll.measureScrollOffset is not work. **/
112
- get scrollOffset(): number;
113
- static ɵfac: i0.ɵɵFactoryDeclaration<CdkDynamicSizeVirtualScroll, never>;
114
- 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>;
115
- }
@@ -1,41 +0,0 @@
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
- /**
10
- * Save scroll amount for next view enter.
11
- */
12
- onDestroy(virtualScroll: CdkVirtualScrollViewport): number;
13
- /**
14
- * Change itemDynamicSize[] to style.height[].
15
- * require itemDynamicSize has 'source' and 'itemSize'.
16
- */
17
- getBindDynamicItemHeight($calcDynamicItemSize: Signal<itemDynamicSize[]>): Signal<string[]>;
18
- /**
19
- * If change the array of hidden areas during scrolling,
20
- * a layout shift will occur. (If not reverse, refers to the array located above the display area.)
21
- * This function confirms that it is OK to change the array.
22
- */
23
- isEnableMerge(virtualScroll: CdkVirtualScrollViewport): boolean;
24
- /**
25
- * When an array is destructively replaced,
26
- * the height of the viewport may remain the same as the sum of the previous array.
27
- * This force it to be initialized.
28
- */
29
- refreshViewport(virtualScroll: CdkVirtualScrollViewport): void;
30
- /**
31
- * This is for smooth scrolling to the top.
32
- */
33
- scrollToTopSmooth(virtualScroll: CdkVirtualScrollViewport): Promise<void>;
34
- /**
35
- * This is for smooth scrolling to a specific point.
36
- * https://github.com/ionic-team/ionic-framework/blob/main/core/src/components/content/content.tsx#L357C3-L404C4
37
- */
38
- scrollToPoint(el: CdkVirtualScrollViewport, x: number | undefined | null, y: number | undefined | null, duration?: number): Promise<void>;
39
- static ɵfac: i0.ɵɵFactoryDeclaration<DynamicSizeVirtualScrollService, never>;
40
- static ɵprov: i0.ɵɵInjectableDeclaration<DynamicSizeVirtualScrollService>;
41
- }
package/public-api.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export * from './lib/dynamic-size-virtual-scroll.service';
2
- export * from './lib/dynamic-size-virtual-scroll-strategy';