ng-virtual-list 17.0.13 → 17.0.14
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/esm2022/lib/components/ng-virtual-list-item.component.mjs +4 -4
- package/esm2022/lib/ng-virtual-list.component.mjs +12 -29
- package/esm2022/lib/utils/cacheMap.mjs +32 -8
- package/esm2022/lib/utils/trackBox.mjs +118 -52
- package/fesm2022/ng-virtual-list.mjs +162 -89
- package/fesm2022/ng-virtual-list.mjs.map +1 -1
- package/lib/components/ng-virtual-list-item.component.d.ts +3 -3
- package/lib/ng-virtual-list.component.d.ts +3 -3
- package/lib/utils/cacheMap.d.ts +16 -9
- package/lib/utils/trackBox.d.ts +32 -15
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { TemplateRef } from '@angular/core';
|
|
2
2
|
import { IRenderVirtualListItem } from '../models/render-item.model';
|
|
3
|
-
import {
|
|
3
|
+
import { ISize } from '../types';
|
|
4
4
|
import * as i0 from "@angular/core";
|
|
5
5
|
/**
|
|
6
6
|
* Virtual list item component
|
|
7
|
-
* @link https://github.com/DjonnyX/ng-virtual-list/blob/
|
|
7
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/19.x/projects/ng-virtual-list/src/lib/components/ng-virtual-list-item.component.ts
|
|
8
8
|
* @author Evgenii Grebennikov
|
|
9
9
|
* @email djonnyx@gmail.com
|
|
10
10
|
*/
|
|
@@ -23,7 +23,7 @@ export declare class NgVirtualListItemComponent {
|
|
|
23
23
|
private _elementRef;
|
|
24
24
|
get element(): HTMLElement;
|
|
25
25
|
constructor();
|
|
26
|
-
getBounds():
|
|
26
|
+
getBounds(): ISize;
|
|
27
27
|
show(): void;
|
|
28
28
|
hide(): void;
|
|
29
29
|
static ɵfac: i0.ɵɵFactoryDeclaration<NgVirtualListItemComponent, never>;
|
|
@@ -2,14 +2,14 @@ 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,
|
|
5
|
+
import { Id, ISize } from './types';
|
|
6
6
|
import { Direction } from './enums';
|
|
7
7
|
import * as i0 from "@angular/core";
|
|
8
8
|
/**
|
|
9
9
|
* Virtual list component.
|
|
10
10
|
* Maximum performance for extremely large lists.
|
|
11
11
|
* It is based on algorithms for virtualization of screen objects.
|
|
12
|
-
* @link https://github.com/DjonnyX/ng-virtual-list/blob/
|
|
12
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/19.x/projects/ng-virtual-list/src/lib/ng-virtual-list.component.ts
|
|
13
13
|
* @author Evgenii Grebennikov
|
|
14
14
|
* @email djonnyx@gmail.com
|
|
15
15
|
*/
|
|
@@ -111,7 +111,7 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnDestroy
|
|
|
111
111
|
/**
|
|
112
112
|
* Returns the bounds of an element with a given id
|
|
113
113
|
*/
|
|
114
|
-
getItemBounds(id: Id):
|
|
114
|
+
getItemBounds(id: Id): ISize | undefined;
|
|
115
115
|
/**
|
|
116
116
|
* The method scrolls the list to the element with the given id and returns the value of the scrolled area.
|
|
117
117
|
* Behavior accepts the values "auto", "instant" and "smooth".
|
package/lib/utils/cacheMap.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { ScrollDirection } from "../models";
|
|
2
|
-
import { EventEmitter
|
|
2
|
+
import { EventEmitter } from "./eventEmitter";
|
|
3
|
+
export declare class CMap<K = string, V = any> {
|
|
4
|
+
private _dict;
|
|
5
|
+
constructor(dict?: CMap<K, V>);
|
|
6
|
+
get(key: K): V;
|
|
7
|
+
set(key: K, value: V): this;
|
|
8
|
+
has(key: K): boolean;
|
|
9
|
+
delete(key: K): void;
|
|
10
|
+
clear(): void;
|
|
11
|
+
}
|
|
3
12
|
export interface ICacheMap<I = any, B = any> {
|
|
4
|
-
set: (id: I, bounds: B) =>
|
|
13
|
+
set: (id: I, bounds: B) => CMap<I, B>;
|
|
5
14
|
has: (id: I) => boolean;
|
|
6
15
|
get: (id: I) => B | undefined;
|
|
7
|
-
forEach: (callbackfn: (value: B, key: I, map: Map<I, B>) => void, thisArg?: any) => void;
|
|
8
16
|
}
|
|
9
17
|
type CacheMapEvents = 'change';
|
|
10
18
|
type OnChangeEventListener = (version: number) => void;
|
|
@@ -12,13 +20,13 @@ type CacheMapListeners = OnChangeEventListener;
|
|
|
12
20
|
/**
|
|
13
21
|
* Cache map.
|
|
14
22
|
* Emits a change event on each mutation.
|
|
15
|
-
* @link https://github.com/DjonnyX/ng-virtual-list/blob/
|
|
23
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/19.x/projects/ng-virtual-list/src/lib/utils/cacheMap.ts
|
|
16
24
|
* @author Evgenii Grebennikov
|
|
17
25
|
* @email djonnyx@gmail.com
|
|
18
26
|
*/
|
|
19
|
-
export declare class CacheMap<I = string | number, B = any, E
|
|
20
|
-
protected _map:
|
|
21
|
-
protected _snapshot:
|
|
27
|
+
export declare class CacheMap<I = string | number, B = any, E = CacheMapEvents, L = CacheMapListeners> extends EventEmitter<E, L> implements ICacheMap {
|
|
28
|
+
protected _map: CMap<I, B>;
|
|
29
|
+
protected _snapshot: CMap<I, B>;
|
|
22
30
|
protected _version: number;
|
|
23
31
|
protected _delta: number;
|
|
24
32
|
get delta(): number;
|
|
@@ -35,10 +43,9 @@ export declare class CacheMap<I = string | number, B = any, E extends string = C
|
|
|
35
43
|
private calcScrollDirection;
|
|
36
44
|
protected bumpVersion(): void;
|
|
37
45
|
protected fireChange(): void;
|
|
38
|
-
set(id: I, bounds: B):
|
|
46
|
+
set(id: I, bounds: B): CMap<I, B>;
|
|
39
47
|
has(id: I): boolean;
|
|
40
48
|
get(id: I): B | undefined;
|
|
41
|
-
forEach(callbackfn: (value: B, key: I, map: Map<I, B>) => void, thisArg?: any): void;
|
|
42
49
|
snapshot(): void;
|
|
43
50
|
dispose(): void;
|
|
44
51
|
}
|
package/lib/utils/trackBox.d.ts
CHANGED
|
@@ -3,8 +3,7 @@ import { NgVirtualListItemComponent } from "../components/ng-virtual-list-item.c
|
|
|
3
3
|
import { IRenderVirtualListCollection } from "../models/render-collection.model";
|
|
4
4
|
import { IRenderVirtualListItem } from "../models/render-item.model";
|
|
5
5
|
import { Id } from "../types/id";
|
|
6
|
-
import {
|
|
7
|
-
import { CacheMap } from "./cacheMap";
|
|
6
|
+
import { CacheMap, CMap } from "./cacheMap";
|
|
8
7
|
import { Tracker } from "./tracker";
|
|
9
8
|
import { ISize } from "../types";
|
|
10
9
|
import { HEIGHT_PROP_NAME, WIDTH_PROP_NAME } from "../const";
|
|
@@ -31,7 +30,6 @@ export interface IMetrics {
|
|
|
31
30
|
rightItemsWeight: number;
|
|
32
31
|
scrollSize: number;
|
|
33
32
|
leftSizeOfAddedItems: number;
|
|
34
|
-
rightSizeOfAddedItems: number;
|
|
35
33
|
sizeProperty: typeof HEIGHT_PROP_NAME | typeof WIDTH_PROP_NAME;
|
|
36
34
|
snap: boolean;
|
|
37
35
|
snippedPos: number;
|
|
@@ -55,6 +53,19 @@ export interface IRecalculateMetricsOptions<I extends {
|
|
|
55
53
|
snap: boolean;
|
|
56
54
|
enabledBufferOptimization: boolean;
|
|
57
55
|
fromItemId?: Id;
|
|
56
|
+
previousTotalSize: number;
|
|
57
|
+
crudDetected: boolean;
|
|
58
|
+
deletedItemsMap: {
|
|
59
|
+
[index: number]: ISize;
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export interface IGetItemPositionOptions<I extends {
|
|
63
|
+
id: Id;
|
|
64
|
+
}, C extends Array<I>> extends Omit<IRecalculateMetricsOptions<I, C>, 'previousTotalSize' | 'crudDetected' | 'deletedItemsMap'> {
|
|
65
|
+
}
|
|
66
|
+
export interface IUpdateCollectionOptions<I extends {
|
|
67
|
+
id: Id;
|
|
68
|
+
}, C extends Array<I>> extends Omit<IRecalculateMetricsOptions<I, C>, 'collection' | 'previousTotalSize' | 'crudDetected' | 'deletedItemsMap'> {
|
|
58
69
|
}
|
|
59
70
|
type CacheMapEvents = typeof TRACK_BOX_CHANGE_EVENT_NAME;
|
|
60
71
|
type OnChangeEventListener = (version: number) => void;
|
|
@@ -65,13 +76,19 @@ declare enum ItemDisplayMethods {
|
|
|
65
76
|
DELETE = 2,
|
|
66
77
|
NOT_CHANGED = 3
|
|
67
78
|
}
|
|
79
|
+
interface IUpdateCollectionReturns {
|
|
80
|
+
displayItems: IRenderVirtualListCollection;
|
|
81
|
+
totalSize: number;
|
|
82
|
+
delta: number;
|
|
83
|
+
crudDetected: boolean;
|
|
84
|
+
}
|
|
68
85
|
/**
|
|
69
86
|
* An object that performs tracking, calculations and caching.
|
|
70
|
-
* @link https://github.com/DjonnyX/ng-virtual-list/blob/
|
|
87
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/19.x/projects/ng-virtual-list/src/lib/utils/trackBox.ts
|
|
71
88
|
* @author Evgenii Grebennikov
|
|
72
89
|
* @email djonnyx@gmail.com
|
|
73
90
|
*/
|
|
74
|
-
export declare class TrackBox extends CacheMap<Id,
|
|
91
|
+
export declare class TrackBox extends CacheMap<Id, ISize & {
|
|
75
92
|
method?: ItemDisplayMethods;
|
|
76
93
|
}, CacheMapEvents, CacheMapListeners> {
|
|
77
94
|
protected _tracker: Tracker<IRenderVirtualListItem, NgVirtualListItemComponent>;
|
|
@@ -84,11 +101,17 @@ export declare class TrackBox extends CacheMap<Id, IRect & {
|
|
|
84
101
|
*/
|
|
85
102
|
set trackingPropertyName(v: string);
|
|
86
103
|
constructor(trackingPropertyName: string);
|
|
87
|
-
set(id: Id, bounds:
|
|
104
|
+
set(id: Id, bounds: ISize): CMap<Id, ISize>;
|
|
88
105
|
private _fireChanges;
|
|
89
106
|
private _previousCollection;
|
|
107
|
+
private _deletedItemsMap;
|
|
108
|
+
private _crudDetected;
|
|
109
|
+
get crudDetected(): boolean;
|
|
90
110
|
private _debounceChanges;
|
|
91
111
|
protected fireChange(): void;
|
|
112
|
+
private _previousTotalSize;
|
|
113
|
+
protected _scrollDelta: number;
|
|
114
|
+
get scrollDelta(): number;
|
|
92
115
|
/**
|
|
93
116
|
* Scans the collection for deleted items and flushes the deleted item cache.
|
|
94
117
|
*/
|
|
@@ -106,17 +129,13 @@ export declare class TrackBox extends CacheMap<Id, IRect & {
|
|
|
106
129
|
*/
|
|
107
130
|
getItemPosition<I extends {
|
|
108
131
|
id: Id;
|
|
109
|
-
}, C extends Array<I>>(id: Id, stickyMap: IVirtualListStickyMap, options:
|
|
132
|
+
}, C extends Array<I>>(id: Id, stickyMap: IVirtualListStickyMap, options: IGetItemPositionOptions<I, C>): number;
|
|
110
133
|
/**
|
|
111
134
|
* Updates the collection of display objects
|
|
112
135
|
*/
|
|
113
136
|
updateCollection<I extends {
|
|
114
137
|
id: Id;
|
|
115
|
-
}, C extends Array<I>>(items: C, stickyMap: IVirtualListStickyMap, options:
|
|
116
|
-
displayItems: IRenderVirtualListCollection;
|
|
117
|
-
totalSize: number;
|
|
118
|
-
delta: number;
|
|
119
|
-
};
|
|
138
|
+
}, C extends Array<I>>(items: C, stickyMap: IVirtualListStickyMap, options: IUpdateCollectionOptions<I, C>): IUpdateCollectionReturns;
|
|
120
139
|
/**
|
|
121
140
|
* Finds the closest element in the collection by scrollSize
|
|
122
141
|
*/
|
|
@@ -137,8 +156,6 @@ export declare class TrackBox extends CacheMap<Id, IRect & {
|
|
|
137
156
|
protected recalculateMetrics<I extends {
|
|
138
157
|
id: Id;
|
|
139
158
|
}, C extends Array<I>>(options: IRecalculateMetricsOptions<I, C>): IMetrics;
|
|
140
|
-
protected _scrollDelta: number;
|
|
141
|
-
get scrollDelta(): number;
|
|
142
159
|
clearDeltaDirection(): void;
|
|
143
160
|
clearDelta(clearDirectionDetector?: boolean): void;
|
|
144
161
|
changes(): void;
|
|
@@ -153,7 +170,7 @@ export declare class TrackBox extends CacheMap<Id, IRect & {
|
|
|
153
170
|
[id: number]: number;
|
|
154
171
|
}): void;
|
|
155
172
|
untrackComponentByIdProperty(component?: NgVirtualListItemComponent | undefined): void;
|
|
156
|
-
getItemBounds(id: Id):
|
|
173
|
+
getItemBounds(id: Id): ISize | undefined;
|
|
157
174
|
protected cacheElements(): void;
|
|
158
175
|
dispose(): void;
|
|
159
176
|
}
|