ng-virtual-list 19.1.19 → 19.1.21
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 +1 -0
- package/fesm2022/ng-virtual-list.mjs +145 -41
- package/fesm2022/ng-virtual-list.mjs.map +1 -1
- package/lib/const/index.d.ts +1 -0
- package/lib/models/scroll-event.model.d.ts +28 -0
- package/lib/ng-virtual-list.component.d.ts +14 -2
- package/lib/utils/cacheMap.d.ts +1 -1
- package/lib/utils/collection.d.ts +12 -1
- package/lib/utils/scrollEvent.d.ts +18 -1
- package/lib/utils/trackBox.d.ts +9 -0
- package/package.json +1 -1
package/lib/const/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare const DEFAULT_ITEM_SIZE = 24;
|
|
|
3
3
|
export declare const DEFAULT_ITEMS_OFFSET = 2;
|
|
4
4
|
export declare const DEFAULT_LIST_SIZE = 400;
|
|
5
5
|
export declare const DEFAULT_SNAP = false;
|
|
6
|
+
export declare const DEFAULT_ENABLED_BUFFER_OPTIMIZATION = true;
|
|
6
7
|
export declare const DEFAULT_SNAP_TO_ITEM = false;
|
|
7
8
|
export declare const DEFAULT_DYNAMIC_SIZE = false;
|
|
8
9
|
export declare const TRACK_BY_PROPERTY_NAME = "id";
|
|
@@ -10,13 +10,41 @@ export interface IScrollEvent {
|
|
|
10
10
|
* Scroll area offset
|
|
11
11
|
*/
|
|
12
12
|
scrollSize: number;
|
|
13
|
+
/**
|
|
14
|
+
* Full size of the scroll area
|
|
15
|
+
*/
|
|
16
|
+
scrollWeight: number;
|
|
17
|
+
/**
|
|
18
|
+
* Viewport size
|
|
19
|
+
*/
|
|
20
|
+
size: number;
|
|
21
|
+
/**
|
|
22
|
+
* Size of the list of elements
|
|
23
|
+
*/
|
|
24
|
+
listSize: number;
|
|
25
|
+
/**
|
|
26
|
+
* Specifies whether the list orientation is vertical.
|
|
27
|
+
*/
|
|
28
|
+
isVertical: boolean;
|
|
13
29
|
/**
|
|
14
30
|
* A value of -1 indicates the direction is up or left (if the list direction is horizontal).
|
|
15
31
|
* A value of 1 indicates the direction is down or right (if the list direction is horizontal).
|
|
16
32
|
*/
|
|
17
33
|
direction: ScrollDirection;
|
|
34
|
+
/**
|
|
35
|
+
* If true then indicates that the list has been scrolled to the end.
|
|
36
|
+
*/
|
|
37
|
+
isStart: boolean;
|
|
18
38
|
/**
|
|
19
39
|
* If true then indicates that the list has been scrolled to the end.
|
|
20
40
|
*/
|
|
21
41
|
isEnd: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Delta of marked and unmarked area
|
|
44
|
+
*/
|
|
45
|
+
delta: number;
|
|
46
|
+
/**
|
|
47
|
+
* Scroll delta
|
|
48
|
+
*/
|
|
49
|
+
scrollDelta: number;
|
|
22
50
|
}
|
|
@@ -2,7 +2,7 @@ import { AfterViewInit, ComponentRef, ElementRef, OnDestroy, TemplateRef, ViewCo
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { NgVirtualListItemComponent } from './components/ng-virtual-list-item.component';
|
|
4
4
|
import { IScrollEvent, IVirtualListCollection, IVirtualListStickyMap } from './models';
|
|
5
|
-
import { Id } from './types';
|
|
5
|
+
import { Id, IRect } from './types';
|
|
6
6
|
import { Direction } from './enums';
|
|
7
7
|
import * as i0 from "@angular/core";
|
|
8
8
|
/**
|
|
@@ -44,6 +44,12 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnDestroy
|
|
|
44
44
|
* Determines whether scroll positions will be snapped to the element. Default value is "false".
|
|
45
45
|
*/
|
|
46
46
|
snapToItem: import("@angular/core").InputSignal<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* Enables buffer optimization.
|
|
49
|
+
* Can only be used if items in the collection are not added or updated. Otherwise, artifacts in the form of twitching of the scroll area are possible.
|
|
50
|
+
* Works only if the property dynamic = true
|
|
51
|
+
*/
|
|
52
|
+
enabledBufferOptimization: import("@angular/core").InputSignal<boolean>;
|
|
47
53
|
/**
|
|
48
54
|
* Rendering element template.
|
|
49
55
|
*/
|
|
@@ -104,6 +110,10 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnDestroy
|
|
|
104
110
|
*/
|
|
105
111
|
protected tracking(): void;
|
|
106
112
|
private resetBoundsSize;
|
|
113
|
+
/**
|
|
114
|
+
* Returns the bounds of an element with a given id
|
|
115
|
+
*/
|
|
116
|
+
getItemBounds(id: Id): IRect | undefined;
|
|
107
117
|
/**
|
|
108
118
|
* The method scrolls the list to the element with the given id and returns the value of the scrolled area.
|
|
109
119
|
* Behavior accepts the values "auto", "instant" and "smooth".
|
|
@@ -113,8 +123,10 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnDestroy
|
|
|
113
123
|
private clearScrollToRepeatExecutionTimeout;
|
|
114
124
|
protected scrollToExecutor(id: Id, behavior: ScrollBehavior, iteration?: number): void;
|
|
115
125
|
scrollToEnd(behavior?: ScrollBehavior): void;
|
|
126
|
+
private _onContainerScrollHandler;
|
|
127
|
+
private _onContainerScrollEndHandler;
|
|
116
128
|
ngAfterViewInit(): void;
|
|
117
129
|
ngOnDestroy(): void;
|
|
118
130
|
static ɵfac: i0.ɵɵFactoryDeclaration<NgVirtualListComponent, never>;
|
|
119
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<NgVirtualListComponent, "ng-virtual-list", never, { "items": { "alias": "items"; "required": true; "isSignal": true; }; "snap": { "alias": "snap"; "required": false; "isSignal": true; }; "snapToItem": { "alias": "snapToItem"; "required": false; "isSignal": true; }; "itemRenderer": { "alias": "itemRenderer"; "required": true; "isSignal": true; }; "stickyMap": { "alias": "stickyMap"; "required": false; "isSignal": true; }; "itemSize": { "alias": "itemSize"; "required": false; "isSignal": true; }; "dynamicSize": { "alias": "dynamicSize"; "required": false; "isSignal": true; }; "direction": { "alias": "direction"; "required": false; "isSignal": true; }; "itemsOffset": { "alias": "itemsOffset"; "required": false; "isSignal": true; }; }, { "onScroll": "onScroll"; "onScrollEnd": "onScrollEnd"; }, never, never, true, never>;
|
|
131
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<NgVirtualListComponent, "ng-virtual-list", never, { "items": { "alias": "items"; "required": true; "isSignal": true; }; "snap": { "alias": "snap"; "required": false; "isSignal": true; }; "snapToItem": { "alias": "snapToItem"; "required": false; "isSignal": true; }; "enabledBufferOptimization": { "alias": "enabledBufferOptimization"; "required": false; "isSignal": true; }; "itemRenderer": { "alias": "itemRenderer"; "required": true; "isSignal": true; }; "stickyMap": { "alias": "stickyMap"; "required": false; "isSignal": true; }; "itemSize": { "alias": "itemSize"; "required": false; "isSignal": true; }; "dynamicSize": { "alias": "dynamicSize"; "required": false; "isSignal": true; }; "direction": { "alias": "direction"; "required": false; "isSignal": true; }; "itemsOffset": { "alias": "itemsOffset"; "required": false; "isSignal": true; }; }, { "onScroll": "onScroll"; "onScrollEnd": "onScrollEnd"; }, never, never, true, never>;
|
|
120
132
|
}
|
package/lib/utils/cacheMap.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ type CacheMapListeners = OnChangeEventListener;
|
|
|
19
19
|
export declare class CacheMap<I = string | number, B = any, E = CacheMapEvents, L = CacheMapListeners> extends EventEmitter<E, L> implements ICacheMap {
|
|
20
20
|
protected _map: Map<I, B>;
|
|
21
21
|
protected _version: number;
|
|
22
|
-
protected
|
|
22
|
+
protected _previouseFullSize: number;
|
|
23
23
|
protected _delta: number;
|
|
24
24
|
get delta(): number;
|
|
25
25
|
protected _deltaDirection: ScrollDirection;
|
|
@@ -1,7 +1,18 @@
|
|
|
1
1
|
import { Id } from "../types";
|
|
2
|
+
interface ICollectionDelta<I extends {
|
|
3
|
+
id: Id;
|
|
4
|
+
}, C extends Array<I>> {
|
|
5
|
+
deletedOrUpdated: C;
|
|
6
|
+
notChanged: C;
|
|
7
|
+
added: C;
|
|
8
|
+
}
|
|
2
9
|
/**
|
|
3
10
|
* Returns the removed or updated elements of a collection.
|
|
11
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/19.x/projects/ng-virtual-list/src/lib/utils/collection.ts
|
|
12
|
+
* @author Evgenii Grebennikov
|
|
13
|
+
* @email djonnyx@gmail.com
|
|
4
14
|
*/
|
|
5
15
|
export declare const getCollectionRemovedOrUpdatedItems: <I extends {
|
|
6
16
|
id: Id;
|
|
7
|
-
}, C extends Array<I>>(previousCollection: C | null | undefined, currentCollection: C | null | undefined) => C
|
|
17
|
+
}, C extends Array<I>>(previousCollection: C | null | undefined, currentCollection: C | null | undefined) => ICollectionDelta<I, C>;
|
|
18
|
+
export {};
|
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import { IScrollEvent, ScrollDirection } from "../models";
|
|
2
|
+
interface IScrollEventParams {
|
|
3
|
+
direction: ScrollDirection;
|
|
4
|
+
container: HTMLElement;
|
|
5
|
+
list: HTMLElement;
|
|
6
|
+
delta: number;
|
|
7
|
+
scrollDelta: number;
|
|
8
|
+
isVertical: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Scroll event.
|
|
12
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/19.x/projects/ng-virtual-list/src/lib/utils/scrollEvent.ts
|
|
13
|
+
* @author Evgenii Grebennikov
|
|
14
|
+
* @email djonnyx@gmail.com
|
|
15
|
+
*/
|
|
2
16
|
export declare class ScrollEvent implements IScrollEvent {
|
|
3
17
|
private _direction;
|
|
4
18
|
get direction(): ScrollDirection;
|
|
@@ -18,5 +32,8 @@ export declare class ScrollEvent implements IScrollEvent {
|
|
|
18
32
|
get isEnd(): boolean;
|
|
19
33
|
private _delta;
|
|
20
34
|
get delta(): number;
|
|
21
|
-
|
|
35
|
+
private _scrollDelta;
|
|
36
|
+
get scrollDelta(): number;
|
|
37
|
+
constructor(params: IScrollEventParams);
|
|
22
38
|
}
|
|
39
|
+
export {};
|
package/lib/utils/trackBox.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export interface IMetrics {
|
|
|
30
30
|
rightItemLength: number;
|
|
31
31
|
rightItemsWeight: number;
|
|
32
32
|
scrollSize: number;
|
|
33
|
+
sizeOfAddedItems: number;
|
|
33
34
|
sizeProperty: typeof HEIGHT_PROP_NAME | typeof WIDTH_PROP_NAME;
|
|
34
35
|
snap: boolean;
|
|
35
36
|
snippedPos: number;
|
|
@@ -68,9 +69,12 @@ export declare class TrackBox extends CacheMap<Id, IRect, CacheMapEvents, CacheM
|
|
|
68
69
|
set items(v: IRenderVirtualListCollection | null | undefined);
|
|
69
70
|
protected _displayComponents: Array<ComponentRef<NgVirtualListItemComponent>> | null | undefined;
|
|
70
71
|
set displayComponents(v: Array<ComponentRef<NgVirtualListItemComponent>> | null | undefined);
|
|
72
|
+
enabledBufferOptimization: boolean;
|
|
71
73
|
constructor(trackingPropertyName: string);
|
|
72
74
|
set(id: Id, bounds: IRect): Map<Id, IRect>;
|
|
73
75
|
private _fireChanges;
|
|
76
|
+
private _isExistAddedItems;
|
|
77
|
+
private _addedItemsMap;
|
|
74
78
|
private _previousCollection;
|
|
75
79
|
private _debounceChanges;
|
|
76
80
|
protected fireChange(): void;
|
|
@@ -80,6 +84,7 @@ export declare class TrackBox extends CacheMap<Id, IRect, CacheMapEvents, CacheM
|
|
|
80
84
|
resetCollection<I extends {
|
|
81
85
|
id: Id;
|
|
82
86
|
}, C extends Array<I>>(currentCollection: C | null | undefined): void;
|
|
87
|
+
private startScrollDeltaCalculationIfNeed;
|
|
83
88
|
/**
|
|
84
89
|
* Clears the cache of items from the list
|
|
85
90
|
*/
|
|
@@ -122,8 +127,11 @@ export declare class TrackBox extends CacheMap<Id, IRect, CacheMapEvents, CacheM
|
|
|
122
127
|
protected recalculateMetrics<I extends {
|
|
123
128
|
id: Id;
|
|
124
129
|
}, C extends Array<I>>(options: IRecalculateMetricsOptions<I, C>): IMetrics;
|
|
130
|
+
protected _scrollDelta: number;
|
|
131
|
+
get scrollDelta(): number;
|
|
125
132
|
clearDeltaDirection(): void;
|
|
126
133
|
clearDelta(clearDirectionDetector?: boolean): void;
|
|
134
|
+
protected stopScrollDeltaCalculation(): void;
|
|
127
135
|
protected generateDisplayCollection<I extends {
|
|
128
136
|
id: Id;
|
|
129
137
|
}, C extends Array<I>>(items: C, stickyMap: IVirtualListStickyMap, metrics: IMetrics): IRenderVirtualListCollection;
|
|
@@ -135,6 +143,7 @@ export declare class TrackBox extends CacheMap<Id, IRect, CacheMapEvents, CacheM
|
|
|
135
143
|
[id: number]: number;
|
|
136
144
|
}): void;
|
|
137
145
|
untrackComponentByIdProperty(component?: NgVirtualListItemComponent | undefined): void;
|
|
146
|
+
getItemBounds(id: Id): IRect | undefined;
|
|
138
147
|
protected cacheElements(): void;
|
|
139
148
|
/**
|
|
140
149
|
* Returns calculated bounds from cache
|