ng-virtual-list 17.0.21 → 17.0.22
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/ng-package.json +7 -0
- package/package.json +29 -42
- package/src/lib/components/ng-virtual-list-item.component.html +9 -0
- package/src/lib/components/ng-virtual-list-item.component.scss +17 -0
- package/src/lib/components/ng-virtual-list-item.component.spec.ts +23 -0
- package/src/lib/components/ng-virtual-list-item.component.ts +111 -0
- package/src/lib/const/index.ts +67 -0
- package/{lib/enums/direction.d.ts → src/lib/enums/direction.ts} +9 -8
- package/{lib/enums/directions.d.ts → src/lib/enums/directions.ts} +16 -16
- package/{lib/enums/index.d.ts → src/lib/enums/index.ts} +7 -4
- package/{lib/models/collection.model.d.ts → src/lib/models/collection.model.ts} +9 -9
- package/{lib/models/index.d.ts → src/lib/models/index.ts} +13 -6
- package/{lib/models/item.model.d.ts → src/lib/models/item.model.ts} +15 -14
- package/{lib/models/render-collection.model.d.ts → src/lib/models/render-collection.model.ts} +9 -9
- package/{lib/models/render-item-config.model.d.ts → src/lib/models/render-item-config.model.ts} +33 -33
- package/{lib/models/render-item.model.d.ts → src/lib/models/render-item.model.ts} +29 -28
- package/{lib/models/scroll-direction.model.d.ts → src/lib/models/scroll-direction.model.ts} +5 -5
- package/{lib/models/scroll-event.model.d.ts → src/lib/models/scroll-event.model.ts} +51 -50
- package/{lib/models/sticky-map.model.d.ts → src/lib/models/sticky-map.model.ts} +12 -12
- package/src/lib/ng-virtual-list.component.html +5 -0
- package/src/lib/ng-virtual-list.component.scss +28 -0
- package/src/lib/ng-virtual-list.component.spec.ts +23 -0
- package/src/lib/ng-virtual-list.component.ts +543 -0
- package/src/lib/ng-virtual-list.module.ts +12 -0
- package/{lib/types/id.d.ts → src/lib/types/id.ts} +7 -7
- package/{lib/types/index.d.ts → src/lib/types/index.ts} +9 -4
- package/{lib/types/rect.d.ts → src/lib/types/rect.ts} +18 -17
- package/{lib/types/size.d.ts → src/lib/types/size.ts} +16 -16
- package/src/lib/utils/cacheMap.ts +224 -0
- package/src/lib/utils/debounce.ts +31 -0
- package/src/lib/utils/eventEmitter.ts +119 -0
- package/{lib/utils/index.d.ts → src/lib/utils/index.ts} +15 -7
- package/src/lib/utils/isDirection.ts +17 -0
- package/src/lib/utils/scrollEvent.ts +62 -0
- package/src/lib/utils/toggleClassName.ts +14 -0
- package/src/lib/utils/trackBox.ts +839 -0
- package/src/lib/utils/tracker.ts +126 -0
- package/{public-api.d.ts → src/public-api.ts} +8 -4
- package/tsconfig.lib.json +16 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +15 -0
- package/esm2022/lib/components/ng-virtual-list-item.component.mjs +0 -88
- package/esm2022/lib/const/index.mjs +0 -35
- package/esm2022/lib/enums/direction.mjs +0 -2
- package/esm2022/lib/enums/directions.mjs +0 -18
- package/esm2022/lib/enums/index.mjs +0 -3
- package/esm2022/lib/models/collection.model.mjs +0 -3
- package/esm2022/lib/models/index.mjs +0 -2
- package/esm2022/lib/models/item.model.mjs +0 -3
- package/esm2022/lib/models/render-collection.model.mjs +0 -3
- package/esm2022/lib/models/render-item-config.model.mjs +0 -2
- package/esm2022/lib/models/render-item.model.mjs +0 -3
- package/esm2022/lib/models/scroll-direction.model.mjs +0 -2
- package/esm2022/lib/models/scroll-event.model.mjs +0 -2
- package/esm2022/lib/models/sticky-map.model.mjs +0 -2
- package/esm2022/lib/ng-virtual-list.component.mjs +0 -390
- package/esm2022/lib/ng-virtual-list.module.mjs +0 -20
- package/esm2022/lib/types/id.mjs +0 -2
- package/esm2022/lib/types/index.mjs +0 -2
- package/esm2022/lib/types/rect.mjs +0 -2
- package/esm2022/lib/types/size.mjs +0 -2
- package/esm2022/lib/utils/cacheMap.mjs +0 -168
- package/esm2022/lib/utils/debounce.mjs +0 -31
- package/esm2022/lib/utils/eventEmitter.mjs +0 -105
- package/esm2022/lib/utils/index.mjs +0 -8
- package/esm2022/lib/utils/isDirection.mjs +0 -15
- package/esm2022/lib/utils/scrollEvent.mjs +0 -42
- package/esm2022/lib/utils/toggleClassName.mjs +0 -15
- package/esm2022/lib/utils/trackBox.mjs +0 -627
- package/esm2022/lib/utils/tracker.mjs +0 -93
- package/esm2022/ng-virtual-list.mjs +0 -5
- package/esm2022/public-api.mjs +0 -8
- package/fesm2022/ng-virtual-list.mjs +0 -1639
- package/fesm2022/ng-virtual-list.mjs.map +0 -1
- package/index.d.ts +0 -5
- package/lib/components/ng-virtual-list-item.component.d.ts +0 -31
- package/lib/const/index.d.ts +0 -33
- package/lib/ng-virtual-list.component.d.ts +0 -130
- package/lib/ng-virtual-list.module.d.ts +0 -9
- package/lib/utils/cacheMap.d.ts +0 -60
- package/lib/utils/debounce.d.ts +0 -16
- package/lib/utils/eventEmitter.d.ts +0 -40
- package/lib/utils/isDirection.d.ts +0 -8
- package/lib/utils/scrollEvent.d.ts +0 -39
- package/lib/utils/toggleClassName.d.ts +0 -7
- package/lib/utils/trackBox.d.ts +0 -176
- package/lib/utils/tracker.d.ts +0 -44
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export type TEventHandler = (...args: Array<any>) => void;
|
|
2
|
-
/**
|
|
3
|
-
* Simple event emitter
|
|
4
|
-
* @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/utils/eventEmitter.ts
|
|
5
|
-
* @author Evgenii Grebennikov
|
|
6
|
-
* @email djonnyx@gmail.com
|
|
7
|
-
*/
|
|
8
|
-
export declare class EventEmitter<E = string, H = TEventHandler> {
|
|
9
|
-
private _listeners;
|
|
10
|
-
protected _disposed: boolean;
|
|
11
|
-
constructor();
|
|
12
|
-
/**
|
|
13
|
-
* Emits the event
|
|
14
|
-
*/
|
|
15
|
-
dispatch(event: E, ...args: Array<any>): void;
|
|
16
|
-
/**
|
|
17
|
-
* Emits the event async
|
|
18
|
-
*/
|
|
19
|
-
dispatchAsync(event: E, ...args: Array<any>): void;
|
|
20
|
-
/**
|
|
21
|
-
* Returns true if the event listener is already subscribed.
|
|
22
|
-
*/
|
|
23
|
-
hasEventListener(eventName: E, handler: H): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Add event listener
|
|
26
|
-
*/
|
|
27
|
-
addEventListener(eventName: E, handler: H): void;
|
|
28
|
-
/**
|
|
29
|
-
* Remove event listener
|
|
30
|
-
*/
|
|
31
|
-
removeEventListener(eventName: E, handler: H): void;
|
|
32
|
-
/**
|
|
33
|
-
* Remove all listeners
|
|
34
|
-
*/
|
|
35
|
-
removeAllListeners(): void;
|
|
36
|
-
/**
|
|
37
|
-
* Method of destroying handlers
|
|
38
|
-
*/
|
|
39
|
-
dispose(): void;
|
|
40
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Direction } from "../enums";
|
|
2
|
-
/**
|
|
3
|
-
* Determines the axis membership of a virtual list
|
|
4
|
-
* @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/utils/isDirection.ts
|
|
5
|
-
* @author Evgenii Grebennikov
|
|
6
|
-
* @email djonnyx@gmail.com
|
|
7
|
-
*/
|
|
8
|
-
export declare const isDirection: (src: Direction, expected: Direction) => boolean;
|
|
@@ -1,39 +0,0 @@
|
|
|
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/17.x/projects/ng-virtual-list/src/lib/utils/scrollEvent.ts
|
|
13
|
-
* @author Evgenii Grebennikov
|
|
14
|
-
* @email djonnyx@gmail.com
|
|
15
|
-
*/
|
|
16
|
-
export declare class ScrollEvent implements IScrollEvent {
|
|
17
|
-
private _direction;
|
|
18
|
-
get direction(): ScrollDirection;
|
|
19
|
-
private _scrollSize;
|
|
20
|
-
get scrollSize(): number;
|
|
21
|
-
private _scrollWeight;
|
|
22
|
-
get scrollWeight(): number;
|
|
23
|
-
private _isVertical;
|
|
24
|
-
get isVertical(): boolean;
|
|
25
|
-
private _listSize;
|
|
26
|
-
get listSize(): number;
|
|
27
|
-
private _size;
|
|
28
|
-
get size(): number;
|
|
29
|
-
private _isStart;
|
|
30
|
-
get isStart(): boolean;
|
|
31
|
-
private _isEnd;
|
|
32
|
-
get isEnd(): boolean;
|
|
33
|
-
private _delta;
|
|
34
|
-
get delta(): number;
|
|
35
|
-
private _scrollDelta;
|
|
36
|
-
get scrollDelta(): number;
|
|
37
|
-
constructor(params: IScrollEventParams);
|
|
38
|
-
}
|
|
39
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Switch css classes
|
|
3
|
-
* @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/utils/toggleClassName.ts
|
|
4
|
-
* @author Evgenii Grebennikov
|
|
5
|
-
* @email djonnyx@gmail.com
|
|
6
|
-
*/
|
|
7
|
-
export declare const toggleClassName: (el: HTMLElement, className: string, remove?: boolean) => void;
|
package/lib/utils/trackBox.d.ts
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
import { ComponentRef } from "@angular/core";
|
|
2
|
-
import { NgVirtualListItemComponent } from "../components/ng-virtual-list-item.component";
|
|
3
|
-
import { IRenderVirtualListCollection } from "../models/render-collection.model";
|
|
4
|
-
import { IRenderVirtualListItem } from "../models/render-item.model";
|
|
5
|
-
import { Id } from "../types/id";
|
|
6
|
-
import { CacheMap, CMap } from "./cacheMap";
|
|
7
|
-
import { Tracker } from "./tracker";
|
|
8
|
-
import { ISize } from "../types";
|
|
9
|
-
import { HEIGHT_PROP_NAME, WIDTH_PROP_NAME } from "../const";
|
|
10
|
-
import { IVirtualListStickyMap } from "../models";
|
|
11
|
-
export declare const TRACK_BOX_CHANGE_EVENT_NAME = "change";
|
|
12
|
-
export interface IMetrics {
|
|
13
|
-
delta: number;
|
|
14
|
-
normalizedItemWidth: number;
|
|
15
|
-
normalizedItemHeight: number;
|
|
16
|
-
width: number;
|
|
17
|
-
height: number;
|
|
18
|
-
dynamicSize: boolean;
|
|
19
|
-
itemSize: number;
|
|
20
|
-
itemsFromStartToScrollEnd: number;
|
|
21
|
-
itemsFromStartToDisplayEnd: number;
|
|
22
|
-
itemsOnDisplay: number;
|
|
23
|
-
itemsOnDisplayLength: number;
|
|
24
|
-
isVertical: boolean;
|
|
25
|
-
leftHiddenItemsWeight: number;
|
|
26
|
-
leftItemLength: number;
|
|
27
|
-
leftItemsWeight: number;
|
|
28
|
-
renderItems: number;
|
|
29
|
-
rightItemLength: number;
|
|
30
|
-
rightItemsWeight: number;
|
|
31
|
-
scrollSize: number;
|
|
32
|
-
leftSizeOfAddedItems: number;
|
|
33
|
-
sizeProperty: typeof HEIGHT_PROP_NAME | typeof WIDTH_PROP_NAME;
|
|
34
|
-
snap: boolean;
|
|
35
|
-
snippedPos: number;
|
|
36
|
-
startIndex: number;
|
|
37
|
-
startPosition: number;
|
|
38
|
-
totalItemsToDisplayEndWeight: number;
|
|
39
|
-
totalLength: number;
|
|
40
|
-
totalSize: number;
|
|
41
|
-
typicalItemSize: number;
|
|
42
|
-
}
|
|
43
|
-
export interface IRecalculateMetricsOptions<I extends {
|
|
44
|
-
id: Id;
|
|
45
|
-
}, C extends Array<I>> {
|
|
46
|
-
bounds: ISize;
|
|
47
|
-
collection: C;
|
|
48
|
-
isVertical: boolean;
|
|
49
|
-
itemSize: number;
|
|
50
|
-
itemsOffset: number;
|
|
51
|
-
dynamicSize: boolean;
|
|
52
|
-
scrollSize: number;
|
|
53
|
-
snap: boolean;
|
|
54
|
-
enabledBufferOptimization: boolean;
|
|
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'> {
|
|
69
|
-
}
|
|
70
|
-
type CacheMapEvents = typeof TRACK_BOX_CHANGE_EVENT_NAME;
|
|
71
|
-
type OnChangeEventListener = (version: number) => void;
|
|
72
|
-
type CacheMapListeners = OnChangeEventListener;
|
|
73
|
-
declare enum ItemDisplayMethods {
|
|
74
|
-
CREATE = 0,
|
|
75
|
-
UPDATE = 1,
|
|
76
|
-
DELETE = 2,
|
|
77
|
-
NOT_CHANGED = 3
|
|
78
|
-
}
|
|
79
|
-
interface IUpdateCollectionReturns {
|
|
80
|
-
displayItems: IRenderVirtualListCollection;
|
|
81
|
-
totalSize: number;
|
|
82
|
-
delta: number;
|
|
83
|
-
crudDetected: boolean;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* An object that performs tracking, calculations and caching.
|
|
87
|
-
* @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/utils/trackBox.ts
|
|
88
|
-
* @author Evgenii Grebennikov
|
|
89
|
-
* @email djonnyx@gmail.com
|
|
90
|
-
*/
|
|
91
|
-
export declare class TrackBox extends CacheMap<Id, ISize & {
|
|
92
|
-
method?: ItemDisplayMethods;
|
|
93
|
-
}, CacheMapEvents, CacheMapListeners> {
|
|
94
|
-
protected _tracker: Tracker<IRenderVirtualListItem, NgVirtualListItemComponent>;
|
|
95
|
-
protected _items: IRenderVirtualListCollection | null | undefined;
|
|
96
|
-
set items(v: IRenderVirtualListCollection | null | undefined);
|
|
97
|
-
protected _displayComponents: Array<ComponentRef<NgVirtualListItemComponent>> | null | undefined;
|
|
98
|
-
set displayComponents(v: Array<ComponentRef<NgVirtualListItemComponent>> | null | undefined);
|
|
99
|
-
/**
|
|
100
|
-
* Set the trackBy property
|
|
101
|
-
*/
|
|
102
|
-
set trackingPropertyName(v: string);
|
|
103
|
-
constructor(trackingPropertyName: string);
|
|
104
|
-
set(id: Id, bounds: ISize): CMap<Id, ISize>;
|
|
105
|
-
private _previousCollection;
|
|
106
|
-
private _deletedItemsMap;
|
|
107
|
-
private _crudDetected;
|
|
108
|
-
get crudDetected(): boolean;
|
|
109
|
-
protected fireChangeIfNeed(): void;
|
|
110
|
-
private _previousTotalSize;
|
|
111
|
-
protected _scrollDelta: number;
|
|
112
|
-
get scrollDelta(): number;
|
|
113
|
-
protected lifeCircle(): void;
|
|
114
|
-
/**
|
|
115
|
-
* Scans the collection for deleted items and flushes the deleted item cache.
|
|
116
|
-
*/
|
|
117
|
-
resetCollection<I extends {
|
|
118
|
-
id: Id;
|
|
119
|
-
}, C extends Array<I>>(currentCollection: C | null | undefined, itemSize: number): void;
|
|
120
|
-
/**
|
|
121
|
-
* Update the cache of items from the list
|
|
122
|
-
*/
|
|
123
|
-
protected updateCache<I extends {
|
|
124
|
-
id: Id;
|
|
125
|
-
}, C extends Array<I>>(previousCollection: C | null | undefined, currentCollection: C | null | undefined, itemSize: number): void;
|
|
126
|
-
/**
|
|
127
|
-
* Finds the position of a collection element by the given Id
|
|
128
|
-
*/
|
|
129
|
-
getItemPosition<I extends {
|
|
130
|
-
id: Id;
|
|
131
|
-
}, C extends Array<I>>(id: Id, stickyMap: IVirtualListStickyMap, options: IGetItemPositionOptions<I, C>): number;
|
|
132
|
-
/**
|
|
133
|
-
* Updates the collection of display objects
|
|
134
|
-
*/
|
|
135
|
-
updateCollection<I extends {
|
|
136
|
-
id: Id;
|
|
137
|
-
}, C extends Array<I>>(items: C, stickyMap: IVirtualListStickyMap, options: IUpdateCollectionOptions<I, C>): IUpdateCollectionReturns;
|
|
138
|
-
/**
|
|
139
|
-
* Finds the closest element in the collection by scrollSize
|
|
140
|
-
*/
|
|
141
|
-
getNearestItem<I extends {
|
|
142
|
-
id: Id;
|
|
143
|
-
}, C extends Array<I>>(scrollSize: number, items: C, itemSize: number, isVertical: boolean): I | undefined;
|
|
144
|
-
/**
|
|
145
|
-
* Calculates the position of an element based on the given scrollSize
|
|
146
|
-
*/
|
|
147
|
-
private getElementFromStart;
|
|
148
|
-
/**
|
|
149
|
-
* Calculates the entry into the overscroll area and returns the number of overscroll elements
|
|
150
|
-
*/
|
|
151
|
-
private getElementNumToEnd;
|
|
152
|
-
/**
|
|
153
|
-
* Calculates list metrics
|
|
154
|
-
*/
|
|
155
|
-
protected recalculateMetrics<I extends {
|
|
156
|
-
id: Id;
|
|
157
|
-
}, C extends Array<I>>(options: IRecalculateMetricsOptions<I, C>): IMetrics;
|
|
158
|
-
clearDeltaDirection(): void;
|
|
159
|
-
clearDelta(clearDirectionDetector?: boolean): void;
|
|
160
|
-
changes(): void;
|
|
161
|
-
protected generateDisplayCollection<I extends {
|
|
162
|
-
id: Id;
|
|
163
|
-
}, C extends Array<I>>(items: C, stickyMap: IVirtualListStickyMap, metrics: IMetrics): IRenderVirtualListCollection;
|
|
164
|
-
/**
|
|
165
|
-
* tracking by propName
|
|
166
|
-
*/
|
|
167
|
-
track(): void;
|
|
168
|
-
setDisplayObjectIndexMapById(v: {
|
|
169
|
-
[id: number]: number;
|
|
170
|
-
}): void;
|
|
171
|
-
untrackComponentByIdProperty(component?: NgVirtualListItemComponent | undefined): void;
|
|
172
|
-
getItemBounds(id: Id): ISize | undefined;
|
|
173
|
-
protected cacheElements(): void;
|
|
174
|
-
dispose(): void;
|
|
175
|
-
}
|
|
176
|
-
export {};
|
package/lib/utils/tracker.d.ts
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ComponentRef } from "@angular/core";
|
|
2
|
-
import { ScrollDirection } from "../models";
|
|
3
|
-
interface IVirtualListItemComponent<I = any> {
|
|
4
|
-
id: number;
|
|
5
|
-
item: I;
|
|
6
|
-
show: () => void;
|
|
7
|
-
hide: () => void;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Tracks display items by property
|
|
11
|
-
* @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/utils/tracker.ts
|
|
12
|
-
* @author Evgenii Grebennikov
|
|
13
|
-
* @email djonnyx@gmail.com
|
|
14
|
-
*/
|
|
15
|
-
export declare class Tracker<I = any, C extends IVirtualListItemComponent = any> {
|
|
16
|
-
/**
|
|
17
|
-
* display objects dictionary of indexes by id
|
|
18
|
-
*/
|
|
19
|
-
private _displayObjectIndexMapById;
|
|
20
|
-
set displayObjectIndexMapById(v: {
|
|
21
|
-
[id: number]: number;
|
|
22
|
-
});
|
|
23
|
-
get displayObjectIndexMapById(): {
|
|
24
|
-
[id: number]: number;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Dictionary displayItems propertyNameId by items propertyNameId
|
|
28
|
-
*/
|
|
29
|
-
private _trackMap;
|
|
30
|
-
get trackMap(): {
|
|
31
|
-
[id: string]: number;
|
|
32
|
-
[id: number]: number;
|
|
33
|
-
} | null;
|
|
34
|
-
private _trackingPropertyName;
|
|
35
|
-
set trackingPropertyName(v: string);
|
|
36
|
-
constructor(trackingPropertyName: string);
|
|
37
|
-
/**
|
|
38
|
-
* tracking by propName
|
|
39
|
-
*/
|
|
40
|
-
track(items: Array<any>, components: Array<ComponentRef<C>>, direction: ScrollDirection): void;
|
|
41
|
-
untrackComponentByIdProperty(component?: C): void;
|
|
42
|
-
dispose(): void;
|
|
43
|
-
}
|
|
44
|
-
export {};
|