ng-virtual-list 16.1.4 → 16.3.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.
Files changed (34) hide show
  1. package/README.md +5 -5
  2. package/esm2022/lib/components/ng-virtual-list-item.component.mjs +9 -6
  3. package/esm2022/lib/enums/direction.mjs +1 -1
  4. package/esm2022/lib/models/base-virtual-list-item-component.mjs +9 -0
  5. package/esm2022/lib/models/collection.model.mjs +1 -1
  6. package/esm2022/lib/models/component.model.mjs +2 -0
  7. package/esm2022/lib/models/index.mjs +3 -2
  8. package/esm2022/lib/models/item.model.mjs +1 -2
  9. package/esm2022/lib/models/render-item-config.model.mjs +1 -1
  10. package/esm2022/lib/models/sticky-map.model.mjs +1 -1
  11. package/esm2022/lib/ng-virtual-list.component.mjs +37 -13
  12. package/esm2022/lib/utils/index.mjs +4 -3
  13. package/esm2022/lib/utils/toggleClassName.mjs +4 -4
  14. package/esm2022/lib/utils/trackBox.mjs +77 -18
  15. package/esm2022/lib/utils/tracker.mjs +23 -3
  16. package/esm2022/public-api.mjs +2 -1
  17. package/fesm2022/ng-virtual-list.mjs +152 -38
  18. package/fesm2022/ng-virtual-list.mjs.map +1 -1
  19. package/lib/components/ng-virtual-list-item.component.d.ts +2 -1
  20. package/lib/enums/direction.d.ts +1 -1
  21. package/lib/models/base-virtual-list-item-component.d.ts +25 -0
  22. package/lib/models/collection.model.d.ts +1 -1
  23. package/lib/models/component.model.d.ts +3 -0
  24. package/lib/models/index.d.ts +4 -1
  25. package/lib/models/item.model.d.ts +2 -2
  26. package/lib/models/render-item-config.model.d.ts +4 -0
  27. package/lib/models/sticky-map.model.d.ts +4 -2
  28. package/lib/ng-virtual-list.component.d.ts +59 -44
  29. package/lib/utils/index.d.ts +4 -2
  30. package/lib/utils/toggleClassName.d.ts +1 -1
  31. package/lib/utils/trackBox.d.ts +30 -22
  32. package/lib/utils/tracker.d.ts +7 -5
  33. package/package.json +1 -1
  34. package/public-api.d.ts +1 -0
@@ -1,6 +1,7 @@
1
1
  import { ChangeDetectorRef, ElementRef, TemplateRef } from '@angular/core';
2
2
  import { IRenderVirtualListItem } from '../models/render-item.model';
3
3
  import { ISize } from '../types';
4
+ import { BaseVirtualListItemComponent } from '../models';
4
5
  import * as i0 from "@angular/core";
5
6
  /**
6
7
  * Virtual list item component
@@ -8,7 +9,7 @@ import * as i0 from "@angular/core";
8
9
  * @author Evgenii Grebennikov
9
10
  * @email djonnyx@gmail.com
10
11
  */
11
- export declare class NgVirtualListItemComponent {
12
+ export declare class NgVirtualListItemComponent extends BaseVirtualListItemComponent {
12
13
  private _cdr;
13
14
  private _elementRef;
14
15
  private static __nextId;
@@ -5,4 +5,4 @@ import { Directions } from "./directions";
5
5
  * @author Evgenii Grebennikov
6
6
  * @email djonnyx@gmail.com
7
7
  */
8
- export type Direction = Directions | 'hotizontal' | 'vertical';
8
+ export type Direction = Directions | 'horizontal' | 'vertical';
@@ -0,0 +1,25 @@
1
+ import { TemplateRef } from '@angular/core';
2
+ import { Id, ISize } from '../types';
3
+ import { IRenderVirtualListItem } from './render-item.model';
4
+ /**
5
+ * Virtual List Item Interface
6
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/16.x/projects/ng-virtual-list/src/lib/models/base-virtual-list-item-component.ts
7
+ * @author Evgenii Grebennikov
8
+ * @email djonnyx@gmail.com
9
+ */
10
+ export declare abstract class BaseVirtualListItemComponent {
11
+ abstract get id(): number;
12
+ abstract data: IRenderVirtualListItem | undefined;
13
+ abstract regular: boolean;
14
+ abstract set regularLength(v: string);
15
+ abstract set item(v: IRenderVirtualListItem | null | undefined);
16
+ abstract get item(): IRenderVirtualListItem | null | undefined;
17
+ abstract get itemId(): Id | undefined;
18
+ abstract itemRenderer: TemplateRef<any> | undefined;
19
+ abstract set renderer(v: TemplateRef<any> | undefined);
20
+ abstract get element(): HTMLElement;
21
+ protected abstract update(): void;
22
+ abstract getBounds(): ISize;
23
+ abstract show(): void;
24
+ abstract hide(): void;
25
+ }
@@ -5,5 +5,5 @@ import { IVirtualListItem } from "./item.model";
5
5
  * @author Evgenii Grebennikov
6
6
  * @email djonnyx@gmail.com
7
7
  */
8
- export interface IVirtualListCollection extends Array<IVirtualListItem> {
8
+ export interface IVirtualListCollection<E = Object> extends Array<IVirtualListItem<E>> {
9
9
  }
@@ -0,0 +1,3 @@
1
+ export interface Component$1<T> extends Function {
2
+ new (...args: any[]): T;
3
+ }
@@ -3,4 +3,7 @@ import { IScrollEvent } from './scroll-event.model';
3
3
  import { IVirtualListItem } from './item.model';
4
4
  import { IVirtualListStickyMap } from './sticky-map.model';
5
5
  import { IVirtualListCollection } from './collection.model';
6
- export type { ScrollDirection, IScrollEvent, IVirtualListItem, IVirtualListStickyMap, IVirtualListCollection, };
6
+ import { BaseVirtualListItemComponent } from './base-virtual-list-item-component';
7
+ import { Component$1 } from './component.model';
8
+ export type { ScrollDirection, IScrollEvent, IVirtualListItem, IVirtualListStickyMap, IVirtualListCollection, Component$1, };
9
+ export { BaseVirtualListItemComponent, };
@@ -5,10 +5,10 @@ import { Id } from "../types/id";
5
5
  * @author Evgenii Grebennikov
6
6
  * @email djonnyx@gmail.com
7
7
  */
8
- export interface IVirtualListItem {
8
+ export type IVirtualListItem<E = Object> = E & {
9
9
  /**
10
10
  * Unique identifier of the element.
11
11
  */
12
12
  id: Id;
13
13
  [x: string]: any;
14
- }
14
+ };
@@ -34,4 +34,8 @@ export interface IRenderVirtualListItemConfig {
34
34
  * Returns true if the snapping method is advanced
35
35
  */
36
36
  isSnappingMethodAdvanced: boolean;
37
+ /**
38
+ * z-index
39
+ */
40
+ zIndex: string;
37
41
  }
@@ -1,5 +1,6 @@
1
1
  /**
2
- * Dictionary zIndex by id of the list element. If the value is not set or equal to 0, then a simple element is displayed, if the value is greater than 0, then the sticky position mode is enabled for the element.
2
+ * Dictionary zIndex by id of the list element. If the value is not set or equal to 0, then a simple element is displayed,
3
+ * if the value is greater than 0, then the sticky position mode is enabled for the element. 1 - position start, 2 - position end.
3
4
  * @link https://github.com/DjonnyX/ng-virtual-list/blob/16.x/projects/ng-virtual-list/src/lib/models/sticky-map.model.ts
4
5
  * @author Evgenii Grebennikov
5
6
  * @email djonnyx@gmail.com
@@ -7,6 +8,7 @@
7
8
  export interface IVirtualListStickyMap {
8
9
  /**
9
10
  * Sets zIndex for the element ID. If zIndex is greater than 0, then sticky position is applied.
11
+ * 1 - position start, 2 - position end.
10
12
  */
11
- [id: string]: number;
13
+ [id: string]: 0 | 1 | 2;
12
14
  }
@@ -1,9 +1,10 @@
1
1
  import { AfterViewInit, ChangeDetectorRef, ComponentRef, ElementRef, EventEmitter, OnDestroy, OnInit, TemplateRef, ViewContainerRef } from '@angular/core';
2
2
  import { BehaviorSubject, Observable } from 'rxjs';
3
- import { NgVirtualListItemComponent } from './components/ng-virtual-list-item.component';
4
- import { IScrollEvent, IVirtualListCollection, IVirtualListStickyMap } from './models';
3
+ import { BaseVirtualListItemComponent, Component$1, IScrollEvent, IVirtualListCollection, IVirtualListStickyMap } from './models';
5
4
  import { Id, ISize } from './types';
5
+ import { IRenderVirtualListCollection } from './models/render-collection.model';
6
6
  import { Direction, SnappingMethod } from './enums';
7
+ import { TrackBox } from './utils';
7
8
  import * as i0 from "@angular/core";
8
9
  /**
9
10
  * Virtual list component.
@@ -14,10 +15,10 @@ import * as i0 from "@angular/core";
14
15
  * @email djonnyx@gmail.com
15
16
  */
16
17
  export declare class NgVirtualListComponent implements AfterViewInit, OnInit, OnDestroy {
17
- private _cdr;
18
- private _elementRef;
19
- private static __nextId;
20
- private _id;
18
+ protected _cdr: ChangeDetectorRef;
19
+ protected _elementRef: ElementRef<HTMLDivElement>;
20
+ protected static __nextId: number;
21
+ protected _id: number;
21
22
  /**
22
23
  * Readonly. Returns the unique identifier of the component.
23
24
  */
@@ -35,22 +36,22 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnInit, On
35
36
  * Fires when the list has completed scrolling.
36
37
  */
37
38
  onScrollEnd: EventEmitter<IScrollEvent>;
38
- private _$items;
39
- readonly $items: Observable<IVirtualListCollection | undefined>;
40
- private _itemsTransform;
39
+ protected _$items: BehaviorSubject<IVirtualListCollection<Object> | undefined>;
40
+ readonly $items: Observable<IVirtualListCollection<Object> | undefined>;
41
+ protected _itemsTransform: (v: IVirtualListCollection | undefined) => IVirtualListCollection<Object> | undefined;
41
42
  /**
42
43
  * Collection of list items.
43
44
  */
44
45
  set items(v: IVirtualListCollection);
45
46
  get items(): IVirtualListCollection;
46
- private _$snap;
47
+ protected _$snap: BehaviorSubject<boolean>;
47
48
  readonly $snap: Observable<boolean>;
48
49
  /**
49
50
  * Determines whether elements will snap. Default value is "true".
50
51
  */
51
52
  set snap(v: boolean);
52
53
  get snap(): boolean;
53
- private _$enabledBufferOptimization;
54
+ protected _$enabledBufferOptimization: BehaviorSubject<boolean>;
54
55
  readonly $enabledBufferOptimization: Observable<boolean>;
55
56
  /**
56
57
  * Experimental!
@@ -60,14 +61,15 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnInit, On
60
61
  */
61
62
  set enabledBufferOptimization(v: boolean);
62
63
  get enabledBufferOptimization(): boolean;
63
- private _$itemRenderer;
64
+ protected _$itemRenderer: BehaviorSubject<TemplateRef<any> | undefined>;
64
65
  readonly $itemRenderer: Observable<TemplateRef<any> | undefined>;
66
+ protected _$renderer: BehaviorSubject<TemplateRef<any> | undefined>;
65
67
  /**
66
68
  * Rendering element template.
67
69
  */
68
70
  set itemRenderer(v: TemplateRef<any>);
69
71
  get itemRenderer(): TemplateRef<any>;
70
- private _$stickyMap;
72
+ protected _$stickyMap: BehaviorSubject<IVirtualListStickyMap>;
71
73
  readonly $stickyMap: Observable<IVirtualListStickyMap>;
72
74
  /**
73
75
  * Dictionary zIndex by id of the list element. If the value is not set or equal to 0,
@@ -75,8 +77,8 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnInit, On
75
77
  */
76
78
  set stickyMap(v: IVirtualListStickyMap);
77
79
  get stickyMap(): IVirtualListStickyMap;
78
- private _itemSizeOptions;
79
- private _$itemSize;
80
+ protected _itemSizeOptions: (v: number | undefined) => number;
81
+ protected _$itemSize: BehaviorSubject<number>;
80
82
  readonly $itemSize: Observable<number>;
81
83
  /**
82
84
  * If direction = 'vertical', then the height of a typical element. If direction = 'horizontal', then the width of a typical element.
@@ -84,7 +86,7 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnInit, On
84
86
  */
85
87
  set itemSize(v: number);
86
88
  get itemSize(): number;
87
- private _$dynamicSize;
89
+ protected _$dynamicSize: BehaviorSubject<boolean>;
88
90
  readonly $dynamicSize: Observable<boolean>;
89
91
  /**
90
92
  * If true then the items in the list can have different sizes and the itemSize property is ignored.
@@ -92,29 +94,29 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnInit, On
92
94
  */
93
95
  set dynamicSize(v: boolean);
94
96
  get dynamicSize(): boolean;
95
- private _$direction;
97
+ protected _$direction: BehaviorSubject<Direction>;
96
98
  readonly $direction: Observable<Direction>;
97
99
  /**
98
100
  * Determines the direction in which elements are placed. Default value is "vertical".
99
101
  */
100
102
  set direction(v: Direction);
101
103
  get direction(): Direction;
102
- private _$itemsOffset;
104
+ protected _$itemsOffset: BehaviorSubject<number>;
103
105
  readonly $itemsOffset: Observable<number>;
104
106
  /**
105
107
  * Number of elements outside the scope of visibility. Default value is 2.
106
108
  */
107
109
  set itemsOffset(v: number);
108
110
  get itemsOffset(): number;
109
- private _$trackBy;
111
+ protected _$trackBy: BehaviorSubject<string>;
110
112
  readonly $trackBy: Observable<string>;
111
113
  /**
112
114
  * The name of the property by which tracking is performed
113
115
  */
114
116
  set trackBy(v: string);
115
117
  get trackBy(): string;
116
- private _isVertical;
117
- private _$snappingMethod;
118
+ protected _isVertical: boolean;
119
+ protected _$snappingMethod: BehaviorSubject<SnappingMethod>;
118
120
  readonly $snappingMethod: Observable<SnappingMethod>;
119
121
  /**
120
122
  * Snapping method.
@@ -124,39 +126,50 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnInit, On
124
126
  set snappingMethod(v: SnappingMethod);
125
127
  get snappingMethod(): SnappingMethod;
126
128
  protected _isSnappingMethodAdvanced: boolean;
127
- protected _displayComponents: Array<ComponentRef<NgVirtualListItemComponent>>;
128
- protected _snapedDisplayComponent: ComponentRef<NgVirtualListItemComponent> | undefined;
129
+ get isSnappingMethodAdvanced(): boolean;
130
+ protected _displayComponents: Array<ComponentRef<BaseVirtualListItemComponent>>;
131
+ protected _snapedDisplayComponent: ComponentRef<BaseVirtualListItemComponent> | undefined;
129
132
  protected _$bounds: BehaviorSubject<ISize | null>;
130
133
  protected _$scrollSize: BehaviorSubject<number>;
131
- private _resizeObserver;
132
- private _resizeSnappedComponentHandler;
133
- private _resizeSnappedObserver;
134
- private _onResizeHandler;
135
- private _onScrollHandler;
136
- private _$initialized;
134
+ protected _resizeObserver: ResizeObserver | null;
135
+ protected _resizeSnappedComponentHandler: () => void;
136
+ protected _resizeSnappedObserver: ResizeObserver | null;
137
+ protected _onResizeHandler: () => void;
138
+ protected _onScrollHandler: (e?: Event) => void;
139
+ protected _$initialized: BehaviorSubject<boolean>;
137
140
  readonly $initialized: Observable<boolean>;
141
+ /**
142
+ * Base class of the element component
143
+ */
144
+ protected _itemComponentClass: Component$1<BaseVirtualListItemComponent>;
145
+ /**
146
+ * Base class trackBox
147
+ */
148
+ protected _trackBoxClass: Component$1<TrackBox>;
138
149
  /**
139
150
  * Dictionary of element sizes by their id
140
151
  */
141
- private _trackBox;
142
- private _onTrackBoxChangeHandler;
143
- private _$cacheVersion;
152
+ protected _trackBox: TrackBox;
153
+ protected _onTrackBoxChangeHandler: (v: number) => void;
154
+ protected _$cacheVersion: BehaviorSubject<number>;
144
155
  get $cacheVersion(): Observable<number>;
145
156
  constructor(_cdr: ChangeDetectorRef, _elementRef: ElementRef<HTMLDivElement>);
157
+ protected setupRenderer(): void;
146
158
  /** @internal */
147
159
  ngOnInit(): void;
148
- private listenCacheChangesIfNeed;
149
- private getIsSnappingMethodAdvanced;
150
- private getIsVertical;
151
- private _componentsResizeObserver;
152
- private createDisplayComponentsIfNeed;
153
- private updateRegularRenderer;
154
- private resetRenderers;
160
+ protected onInit(): void;
161
+ protected listenCacheChangesIfNeed(value: boolean): void;
162
+ protected getIsSnappingMethodAdvanced(m?: SnappingMethod): boolean;
163
+ protected getIsVertical(d?: Direction): boolean;
164
+ protected _componentsResizeObserver: ResizeObserver;
165
+ protected createDisplayComponentsIfNeed(displayItems: IRenderVirtualListCollection | null): void;
166
+ protected updateRegularRenderer(): void;
167
+ protected resetRenderers(itemRenderer?: TemplateRef<HTMLElement>): void;
155
168
  /**
156
169
  * Tracking by id
157
170
  */
158
171
  protected tracking(): void;
159
- private resetBoundsSize;
172
+ protected resetBoundsSize(isVertical: boolean, totalSize: number): void;
160
173
  /**
161
174
  * Returns the bounds of an element with a given id
162
175
  */
@@ -166,19 +179,21 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnInit, On
166
179
  * Behavior accepts the values ​​"auto", "instant" and "smooth".
167
180
  */
168
181
  scrollTo(id: Id, behavior?: ScrollBehavior): void;
169
- private _scrollToRepeatExecutionTimeout;
170
- private clearScrollToRepeatExecutionTimeout;
182
+ protected _scrollToRepeatExecutionTimeout: any;
183
+ protected clearScrollToRepeatExecutionTimeout(): void;
171
184
  protected scrollToExecutor(id: Id, behavior: ScrollBehavior, iteration?: number, isLastIteration?: boolean): void;
172
185
  /**
173
186
  * Scrolls the scroll area to the desired element with the specified ID.
174
187
  */
175
188
  scrollToEnd(behavior?: ScrollBehavior): void;
176
- private _onContainerScrollHandler;
177
- private _onContainerScrollEndHandler;
189
+ protected _onContainerScrollHandler: (e: Event) => void;
190
+ protected _onContainerScrollEndHandler: (e: Event) => void;
178
191
  /** @internal */
179
192
  ngAfterViewInit(): void;
193
+ protected afterViewInit(): void;
180
194
  /** @internal */
181
195
  ngOnDestroy(): void;
196
+ protected dispose(): void;
182
197
  static ɵfac: i0.ɵɵFactoryDeclaration<NgVirtualListComponent, never>;
183
198
  static ɵcmp: i0.ɵɵComponentDeclaration<NgVirtualListComponent, "ng-virtual-list", never, { "items": { "alias": "items"; "required": false; }; "snap": { "alias": "snap"; "required": false; }; "enabledBufferOptimization": { "alias": "enabledBufferOptimization"; "required": false; }; "itemRenderer": { "alias": "itemRenderer"; "required": false; }; "stickyMap": { "alias": "stickyMap"; "required": false; }; "itemSize": { "alias": "itemSize"; "required": false; }; "dynamicSize": { "alias": "dynamicSize"; "required": false; }; "direction": { "alias": "direction"; "required": false; }; "itemsOffset": { "alias": "itemsOffset"; "required": false; }; "trackBy": { "alias": "trackBy"; "required": false; }; "snappingMethod": { "alias": "snappingMethod"; "required": false; }; }, { "onScroll": "onScroll"; "onScrollEnd": "onScrollEnd"; }, never, never, false, never>;
184
199
  }
@@ -2,6 +2,8 @@ import { isDirection } from "./isDirection";
2
2
  import { debounce } from "./debounce";
3
3
  import { toggleClassName } from './toggleClassName';
4
4
  import { Tracker } from "./tracker";
5
- import { TrackBox } from "./trackBox";
5
+ import { TrackBox, IUpdateCollectionReturns, TRACK_BOX_CHANGE_EVENT_NAME, IMetrics, IRecalculateMetricsOptions, IGetItemPositionOptions, IUpdateCollectionOptions, CacheMapEvents, OnChangeEventListener, CacheMapListeners, ItemDisplayMethods } from "./trackBox";
6
+ import { CMap, ICacheMap, CACHE_BOX_CHANGE_EVENT_NAME } from './cacheMap';
6
7
  import { ScrollEvent } from "./scrollEvent";
7
- export { isDirection, debounce, toggleClassName, ScrollEvent, TrackBox, Tracker, };
8
+ export { isDirection, debounce, toggleClassName, ScrollEvent, TrackBox, Tracker, TRACK_BOX_CHANGE_EVENT_NAME, CMap, CACHE_BOX_CHANGE_EVENT_NAME, };
9
+ export type { ICacheMap, IUpdateCollectionReturns, IMetrics, IRecalculateMetricsOptions, IGetItemPositionOptions, IUpdateCollectionOptions, CacheMapEvents, OnChangeEventListener, CacheMapListeners, ItemDisplayMethods, };
@@ -4,4 +4,4 @@
4
4
  * @author Evgenii Grebennikov
5
5
  * @email djonnyx@gmail.com
6
6
  */
7
- export declare const toggleClassName: (el: HTMLElement, className: string, remove?: boolean) => void;
7
+ export declare const toggleClassName: (el: HTMLElement, className: string, removeClassName?: string) => void;
@@ -1,13 +1,11 @@
1
1
  import { ComponentRef } from "@angular/core";
2
- import { NgVirtualListItemComponent } from "../components/ng-virtual-list-item.component";
3
2
  import { IRenderVirtualListCollection } from "../models/render-collection.model";
4
- import { IRenderVirtualListItem } from "../models/render-item.model";
5
3
  import { Id } from "../types/id";
6
4
  import { CacheMap, CMap } from "./cacheMap";
7
5
  import { Tracker } from "./tracker";
8
6
  import { ISize } from "../types";
9
7
  import { HEIGHT_PROP_NAME, WIDTH_PROP_NAME } from "../const";
10
- import { IVirtualListStickyMap } from "../models";
8
+ import { BaseVirtualListItemComponent, IVirtualListStickyMap } from "../models";
11
9
  export declare const TRACK_BOX_CHANGE_EVENT_NAME = "change";
12
10
  export interface IMetrics {
13
11
  delta: number;
@@ -67,16 +65,16 @@ export interface IUpdateCollectionOptions<I extends {
67
65
  id: Id;
68
66
  }, C extends Array<I>> extends Omit<IRecalculateMetricsOptions<I, C>, 'collection' | 'previousTotalSize' | 'crudDetected' | 'deletedItemsMap'> {
69
67
  }
70
- type CacheMapEvents = typeof TRACK_BOX_CHANGE_EVENT_NAME;
71
- type OnChangeEventListener = (version: number) => void;
72
- type CacheMapListeners = OnChangeEventListener;
73
- declare enum ItemDisplayMethods {
68
+ export type CacheMapEvents = typeof TRACK_BOX_CHANGE_EVENT_NAME;
69
+ export type OnChangeEventListener = (version: number) => void;
70
+ export type CacheMapListeners = OnChangeEventListener;
71
+ export declare enum ItemDisplayMethods {
74
72
  CREATE = 0,
75
73
  UPDATE = 1,
76
74
  DELETE = 2,
77
75
  NOT_CHANGED = 3
78
76
  }
79
- interface IUpdateCollectionReturns {
77
+ export interface IUpdateCollectionReturns {
80
78
  displayItems: IRenderVirtualListCollection;
81
79
  totalSize: number;
82
80
  delta: number;
@@ -88,16 +86,16 @@ interface IUpdateCollectionReturns {
88
86
  * @author Evgenii Grebennikov
89
87
  * @email djonnyx@gmail.com
90
88
  */
91
- export declare class TrackBox extends CacheMap<Id, ISize & {
89
+ export declare class TrackBox<C extends BaseVirtualListItemComponent = any> extends CacheMap<Id, ISize & {
92
90
  method?: ItemDisplayMethods;
93
91
  }, CacheMapEvents, CacheMapListeners> {
94
- protected _tracker: Tracker<IRenderVirtualListItem, NgVirtualListItemComponent>;
92
+ protected _tracker: Tracker<C>;
95
93
  protected _items: IRenderVirtualListCollection | null | undefined;
96
94
  set items(v: IRenderVirtualListCollection | null | undefined);
97
- protected _displayComponents: Array<ComponentRef<NgVirtualListItemComponent>> | null | undefined;
98
- set displayComponents(v: Array<ComponentRef<NgVirtualListItemComponent>> | null | undefined);
99
- protected _snapedDisplayComponent: ComponentRef<NgVirtualListItemComponent> | null | undefined;
100
- set snapedDisplayComponent(v: ComponentRef<NgVirtualListItemComponent> | null | undefined);
95
+ protected _displayComponents: Array<ComponentRef<C>> | null | undefined;
96
+ set displayComponents(v: Array<ComponentRef<C>> | null | undefined);
97
+ protected _snapedDisplayComponent: ComponentRef<C> | null | undefined;
98
+ set snapedDisplayComponent(v: ComponentRef<C> | null | undefined);
101
99
  protected _isSnappingMethodAdvanced: boolean;
102
100
  set isSnappingMethodAdvanced(v: boolean);
103
101
  /**
@@ -106,12 +104,16 @@ export declare class TrackBox extends CacheMap<Id, ISize & {
106
104
  set trackingPropertyName(v: string);
107
105
  constructor(trackingPropertyName: string);
108
106
  set(id: Id, bounds: ISize): CMap<Id, ISize>;
109
- private _previousCollection;
110
- private _deletedItemsMap;
111
- private _crudDetected;
107
+ protected _previousCollection: Array<{
108
+ id: Id;
109
+ }> | null | undefined;
110
+ protected _deletedItemsMap: {
111
+ [index: number]: ISize;
112
+ };
113
+ protected _crudDetected: boolean;
112
114
  get crudDetected(): boolean;
113
115
  protected fireChangeIfNeed(): void;
114
- private _previousTotalSize;
116
+ protected _previousTotalSize: number;
115
117
  protected _scrollDelta: number;
116
118
  get scrollDelta(): number;
117
119
  protected lifeCircle(): void;
@@ -148,11 +150,18 @@ export declare class TrackBox extends CacheMap<Id, ISize & {
148
150
  /**
149
151
  * Calculates the position of an element based on the given scrollSize
150
152
  */
151
- private getElementFromStart;
153
+ protected getElementFromStart<I extends {
154
+ id: Id;
155
+ }, C extends Array<I>>(scrollSize: number, collection: C, map: CMap<Id, ISize>, typicalItemSize: number, isVertical: boolean): I | undefined;
152
156
  /**
153
157
  * Calculates the entry into the overscroll area and returns the number of overscroll elements
154
158
  */
155
- private getElementNumToEnd;
159
+ protected getElementNumToEnd<I extends {
160
+ id: Id;
161
+ }, C extends Array<I>>(i: number, collection: C, map: CMap<Id, ISize>, typicalItemSize: number, size: number, isVertical: boolean, indexOffset?: number): {
162
+ num: number;
163
+ offset: number;
164
+ };
156
165
  /**
157
166
  * Calculates list metrics
158
167
  */
@@ -172,9 +181,8 @@ export declare class TrackBox extends CacheMap<Id, ISize & {
172
181
  setDisplayObjectIndexMapById(v: {
173
182
  [id: number]: number;
174
183
  }): void;
175
- untrackComponentByIdProperty(component?: NgVirtualListItemComponent | undefined): void;
184
+ untrackComponentByIdProperty(component?: C | undefined): void;
176
185
  getItemBounds(id: Id): ISize | undefined;
177
186
  protected cacheElements(): void;
178
187
  dispose(): void;
179
188
  }
180
- export {};
@@ -1,8 +1,11 @@
1
1
  import { ComponentRef } from "@angular/core";
2
- import { ScrollDirection } from "../models";
3
- interface IVirtualListItemComponent<I = any> {
2
+ import { BaseVirtualListItemComponent, ScrollDirection } from "../models";
3
+ import { Id, ISize } from "../types";
4
+ export interface IVirtualListItemComponent<I = any> {
5
+ getBounds(): ISize;
6
+ itemId: Id;
4
7
  id: number;
5
- item: I;
8
+ item: I | null;
6
9
  show: () => void;
7
10
  hide: () => void;
8
11
  }
@@ -12,7 +15,7 @@ interface IVirtualListItemComponent<I = any> {
12
15
  * @author Evgenii Grebennikov
13
16
  * @email djonnyx@gmail.com
14
17
  */
15
- export declare class Tracker<I = any, C extends IVirtualListItemComponent = any> {
18
+ export declare class Tracker<C extends BaseVirtualListItemComponent = any> {
16
19
  /**
17
20
  * display objects dictionary of indexes by id
18
21
  */
@@ -41,4 +44,3 @@ export declare class Tracker<I = any, C extends IVirtualListItemComponent = any>
41
44
  untrackComponentByIdProperty(component?: C): void;
42
45
  dispose(): void;
43
46
  }
44
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-virtual-list",
3
- "version": "16.1.4",
3
+ "version": "16.3.0",
4
4
  "author": {
5
5
  "name": "Evgenii Grebennikov",
6
6
  "email": "djonnyx@gmail.com"
package/public-api.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from './lib/components/ng-virtual-list-item.component';
1
2
  export * from './lib/ng-virtual-list.module';
2
3
  export * from './lib/ng-virtual-list.component';
3
4
  export * from './lib/enums';