ng-virtual-list 19.1.21 → 19.1.23

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.
@@ -2,4 +2,4 @@
2
2
  * A value of -1 indicates the direction is up or left (if the list direction is horizontal).
3
3
  * A value of 1 indicates the direction is down or right (if the list direction is horizontal).
4
4
  */
5
- export type ScrollDirection = -1 | 1;
5
+ export type ScrollDirection = -1 | 1 | 0;
@@ -82,6 +82,9 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnDestroy
82
82
  protected _displayComponents: Array<ComponentRef<NgVirtualListItemComponent>>;
83
83
  protected _bounds: WritableSignal<DOMRect | null>;
84
84
  protected _scrollSize: WritableSignal<number>;
85
+ private _isScrollingDebounces;
86
+ private _isScrolling;
87
+ get isScrolling(): boolean;
85
88
  private _resizeObserver;
86
89
  private _onResizeHandler;
87
90
  private _onScrollHandler;
@@ -18,8 +18,8 @@ type CacheMapListeners = OnChangeEventListener;
18
18
  */
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
+ protected _snapshot: Map<I, B>;
21
22
  protected _version: number;
22
- protected _previouseFullSize: number;
23
23
  protected _delta: number;
24
24
  get delta(): number;
25
25
  protected _deltaDirection: ScrollDirection;
@@ -39,6 +39,7 @@ export declare class CacheMap<I = string | number, B = any, E = CacheMapEvents,
39
39
  has(id: I): boolean;
40
40
  get(id: I): B | undefined;
41
41
  forEach(callbackfn: (value: B, key: I, map: Map<I, B>) => void, thisArg?: any): void;
42
+ snapshot(): void;
42
43
  dispose(): void;
43
44
  }
44
45
  export {};
@@ -2,7 +2,8 @@ import { Id } from "../types";
2
2
  interface ICollectionDelta<I extends {
3
3
  id: Id;
4
4
  }, C extends Array<I>> {
5
- deletedOrUpdated: C;
5
+ deleted: C;
6
+ updated: C;
6
7
  notChanged: C;
7
8
  added: C;
8
9
  }
@@ -30,7 +30,8 @@ export interface IMetrics {
30
30
  rightItemLength: number;
31
31
  rightItemsWeight: number;
32
32
  scrollSize: number;
33
- sizeOfAddedItems: number;
33
+ leftSizeOfAddedItems: number;
34
+ rightSizeOfAddedItems: number;
34
35
  sizeProperty: typeof HEIGHT_PROP_NAME | typeof WIDTH_PROP_NAME;
35
36
  snap: boolean;
36
37
  snippedPos: number;
@@ -52,29 +53,35 @@ export interface IRecalculateMetricsOptions<I extends {
52
53
  dynamicSize: boolean;
53
54
  scrollSize: number;
54
55
  snap: boolean;
56
+ enabledBufferOptimization: boolean;
55
57
  fromItemId?: Id;
56
58
  }
57
59
  type CacheMapEvents = typeof TRACK_BOX_CHANGE_EVENT_NAME;
58
60
  type OnChangeEventListener = (version: number) => void;
59
61
  type CacheMapListeners = OnChangeEventListener;
62
+ declare enum ItemDisplayMethods {
63
+ CREATE = 0,
64
+ UPDATE = 1,
65
+ DELETE = 2,
66
+ NOT_CHANGED = 3
67
+ }
60
68
  /**
61
69
  * An object that performs tracking, calculations and caching.
62
70
  * @link https://github.com/DjonnyX/ng-virtual-list/blob/19.x/projects/ng-virtual-list/src/lib/utils/trackBox.ts
63
71
  * @author Evgenii Grebennikov
64
72
  * @email djonnyx@gmail.com
65
73
  */
66
- export declare class TrackBox extends CacheMap<Id, IRect, CacheMapEvents, CacheMapListeners> {
74
+ export declare class TrackBox extends CacheMap<Id, IRect & {
75
+ method?: ItemDisplayMethods;
76
+ }, CacheMapEvents, CacheMapListeners> {
67
77
  protected _tracker: Tracker<IRenderVirtualListItem, NgVirtualListItemComponent>;
68
78
  protected _items: IRenderVirtualListCollection | null | undefined;
69
79
  set items(v: IRenderVirtualListCollection | null | undefined);
70
80
  protected _displayComponents: Array<ComponentRef<NgVirtualListItemComponent>> | null | undefined;
71
81
  set displayComponents(v: Array<ComponentRef<NgVirtualListItemComponent>> | null | undefined);
72
- enabledBufferOptimization: boolean;
73
82
  constructor(trackingPropertyName: string);
74
83
  set(id: Id, bounds: IRect): Map<Id, IRect>;
75
84
  private _fireChanges;
76
- private _isExistAddedItems;
77
- private _addedItemsMap;
78
85
  private _previousCollection;
79
86
  private _debounceChanges;
80
87
  protected fireChange(): void;
@@ -83,14 +90,13 @@ export declare class TrackBox extends CacheMap<Id, IRect, CacheMapEvents, CacheM
83
90
  */
84
91
  resetCollection<I extends {
85
92
  id: Id;
86
- }, C extends Array<I>>(currentCollection: C | null | undefined): void;
87
- private startScrollDeltaCalculationIfNeed;
93
+ }, C extends Array<I>>(currentCollection: C | null | undefined, itemSize: number): void;
88
94
  /**
89
95
  * Clears the cache of items from the list
90
96
  */
91
97
  protected clearCache<I extends {
92
98
  id: Id;
93
- }, C extends Array<I>>(items: C | null | undefined): void;
99
+ }, C extends Array<I>>(deleted: C | null | undefined, updated: C | null | undefined, added: C | null | undefined, itemSize: number): void;
94
100
  /**
95
101
  * Finds the position of a collection element by the given Id
96
102
  */
@@ -131,7 +137,6 @@ export declare class TrackBox extends CacheMap<Id, IRect, CacheMapEvents, CacheM
131
137
  get scrollDelta(): number;
132
138
  clearDeltaDirection(): void;
133
139
  clearDelta(clearDirectionDetector?: boolean): void;
134
- protected stopScrollDeltaCalculation(): void;
135
140
  protected generateDisplayCollection<I extends {
136
141
  id: Id;
137
142
  }, C extends Array<I>>(items: C, stickyMap: IVirtualListStickyMap, metrics: IMetrics): IRenderVirtualListCollection;
@@ -145,10 +150,6 @@ export declare class TrackBox extends CacheMap<Id, IRect, CacheMapEvents, CacheM
145
150
  untrackComponentByIdProperty(component?: NgVirtualListItemComponent | undefined): void;
146
151
  getItemBounds(id: Id): IRect | undefined;
147
152
  protected cacheElements(): void;
148
- /**
149
- * Returns calculated bounds from cache
150
- */
151
- private getBoundsFromCache;
152
153
  dispose(): void;
153
154
  }
154
155
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-virtual-list",
3
- "version": "19.1.21",
3
+ "version": "19.1.23",
4
4
  "author": {
5
5
  "name": "Evgenii Grebennikov",
6
6
  "email": "djonnyx@gmail.com"