ng-virtual-list 17.0.0 → 17.0.2

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 (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +33 -7
  3. package/esm2022/lib/components/ng-virtual-list-item.component.mjs +2 -2
  4. package/esm2022/lib/const/index.mjs +2 -1
  5. package/esm2022/lib/enums/direction.mjs +1 -1
  6. package/esm2022/lib/enums/directions.mjs +2 -2
  7. package/esm2022/lib/models/collection.model.mjs +1 -1
  8. package/esm2022/lib/models/index.mjs +1 -1
  9. package/esm2022/lib/models/item.model.mjs +1 -1
  10. package/esm2022/lib/models/render-collection.model.mjs +1 -1
  11. package/esm2022/lib/models/render-item-config.model.mjs +1 -1
  12. package/esm2022/lib/models/render-item.model.mjs +1 -1
  13. package/esm2022/lib/models/scroll-direction.model.mjs +2 -0
  14. package/esm2022/lib/models/scroll-event.model.mjs +2 -0
  15. package/esm2022/lib/models/sticky-map.model.mjs +1 -1
  16. package/esm2022/lib/ng-virtual-list.component.mjs +44 -47
  17. package/esm2022/lib/types/id.mjs +1 -1
  18. package/esm2022/lib/types/rect.mjs +1 -1
  19. package/esm2022/lib/types/size.mjs +1 -1
  20. package/esm2022/lib/utils/cacheMap.mjs +43 -2
  21. package/esm2022/lib/utils/debounce.mjs +2 -2
  22. package/esm2022/lib/utils/eventEmitter.mjs +2 -2
  23. package/esm2022/lib/utils/isDirection.mjs +2 -2
  24. package/esm2022/lib/utils/toggleClassName.mjs +2 -2
  25. package/esm2022/lib/utils/trackBox.mjs +56 -22
  26. package/esm2022/lib/utils/tracker.mjs +2 -2
  27. package/fesm2022/ng-virtual-list.mjs +146 -74
  28. package/fesm2022/ng-virtual-list.mjs.map +1 -1
  29. package/lib/components/ng-virtual-list-item.component.d.ts +1 -1
  30. package/lib/const/index.d.ts +1 -0
  31. package/lib/enums/direction.d.ts +1 -1
  32. package/lib/enums/directions.d.ts +1 -1
  33. package/lib/models/collection.model.d.ts +1 -1
  34. package/lib/models/index.d.ts +3 -1
  35. package/lib/models/item.model.d.ts +1 -1
  36. package/lib/models/render-collection.model.d.ts +1 -1
  37. package/lib/models/render-item-config.model.d.ts +1 -1
  38. package/lib/models/render-item.model.d.ts +1 -1
  39. package/lib/models/scroll-direction.model.d.ts +5 -0
  40. package/lib/models/scroll-event.model.d.ts +18 -0
  41. package/lib/models/sticky-map.model.d.ts +1 -1
  42. package/lib/ng-virtual-list.component.d.ts +7 -10
  43. package/lib/types/id.d.ts +1 -1
  44. package/lib/types/rect.d.ts +1 -1
  45. package/lib/types/size.d.ts +1 -1
  46. package/lib/utils/cacheMap.d.ts +11 -1
  47. package/lib/utils/debounce.d.ts +1 -1
  48. package/lib/utils/eventEmitter.d.ts +1 -1
  49. package/lib/utils/isDirection.d.ts +1 -1
  50. package/lib/utils/toggleClassName.d.ts +1 -1
  51. package/lib/utils/trackBox.d.ts +4 -4
  52. package/lib/utils/tracker.d.ts +1 -1
  53. package/package.json +1 -1
@@ -4,7 +4,7 @@ import { IVirtualListItem } from "./item.model";
4
4
  import { IRenderVirtualListItemConfig } from "./render-item-config.model";
5
5
  /**
6
6
  * List screen element model
7
- * @link https://github.com/DjonnyX/ng-virtual-list/blob/main/projects/ng-virtual-list/src/lib/models/render-item.model.ts
7
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/models/render-item.model.ts
8
8
  * @author Evgenii Grebennikov
9
9
  * @email djonnyx@gmail.com
10
10
  */
@@ -0,0 +1,5 @@
1
+ /**
2
+ * A value of -1 indicates the direction is up or left (if the list direction is horizontal).
3
+ * A value of 1 indicates the direction is down or right (if the list direction is horizontal).
4
+ */
5
+ export type ScrollDirection = -1 | 1;
@@ -0,0 +1,18 @@
1
+ import { ScrollDirection } from "./scroll-direction.model";
2
+ /**
3
+ * Interface IScrollEvent.
4
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/models/scroll-event.model.ts
5
+ * @author Evgenii Grebennikov
6
+ * @email djonnyx@gmail.com
7
+ */
8
+ export interface IScrollEvent {
9
+ /**
10
+ * Scroll area offset
11
+ */
12
+ scrollSize: number;
13
+ /**
14
+ * A value of -1 indicates the direction is up or left (if the list direction is horizontal).
15
+ * A value of 1 indicates the direction is down or right (if the list direction is horizontal).
16
+ */
17
+ direction: ScrollDirection;
18
+ }
@@ -1,6 +1,6 @@
1
1
  /**
2
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.
3
- * @link https://github.com/DjonnyX/ng-virtual-list/blob/main/projects/ng-virtual-list/src/lib/models/sticky-map.model.ts
3
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/models/sticky-map.model.ts
4
4
  * @author Evgenii Grebennikov
5
5
  * @email djonnyx@gmail.com
6
6
  */
@@ -1,7 +1,7 @@
1
1
  import { AfterViewInit, ComponentRef, ElementRef, OnDestroy, TemplateRef, ViewContainerRef, WritableSignal } from '@angular/core';
2
2
  import { Observable } from 'rxjs';
3
3
  import { NgVirtualListItemComponent } from './components/ng-virtual-list-item.component';
4
- import { IVirtualListCollection, IVirtualListStickyMap } from './models';
4
+ import { IScrollEvent, IVirtualListCollection, IVirtualListStickyMap } from './models';
5
5
  import { Id } from './types';
6
6
  import { Direction } from './enums';
7
7
  import * as i0 from "@angular/core";
@@ -9,7 +9,7 @@ import * as i0 from "@angular/core";
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/main/projects/ng-virtual-list/src/lib/ng-virtual-list.component.ts
12
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/17.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
  */
@@ -26,11 +26,11 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnDestroy
26
26
  /**
27
27
  * Fires when the list has been scrolled.
28
28
  */
29
- onScroll: import("@angular/core").OutputEmitterRef<number>;
29
+ onScroll: import("@angular/core").OutputEmitterRef<IScrollEvent>;
30
30
  /**
31
31
  * Fires when the list has completed scrolling.
32
32
  */
33
- onScrollEnd: import("@angular/core").OutputEmitterRef<number>;
33
+ onScrollEnd: import("@angular/core").OutputEmitterRef<IScrollEvent>;
34
34
  /**
35
35
  * Collection of list items.
36
36
  */
@@ -71,18 +71,12 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnDestroy
71
71
  * Number of elements outside the scope of visibility. Default value is 2.
72
72
  */
73
73
  itemsOffset: import("@angular/core").InputSignal<number>;
74
- private _scrollToTimeout;
75
74
  private _isVertical;
76
75
  protected _displayComponents: Array<ComponentRef<NgVirtualListItemComponent>>;
77
76
  protected _bounds: WritableSignal<DOMRect | null>;
78
77
  protected _scrollSize: WritableSignal<number>;
79
78
  private _resizeObserver;
80
- /**
81
- * only dynamic
82
- */
83
- private _scrolledItemId;
84
79
  private _onResizeHandler;
85
- private _scrollDirection;
86
80
  private _onScrollHandler;
87
81
  private scrollImmediately;
88
82
  private _scrollImmediatelyHandler;
@@ -114,6 +108,9 @@ export declare class NgVirtualListComponent implements AfterViewInit, OnDestroy
114
108
  * Behavior accepts the values ​​"auto", "instant" and "smooth".
115
109
  */
116
110
  scrollTo(id: Id, behavior?: ScrollBehavior): void;
111
+ private _scrollToRepeatExecutionTimeout;
112
+ private clearScrollToRepeatExecutionTimeout;
113
+ protected scrollToExecutor(id: Id, behavior: ScrollBehavior, iteration?: number): void;
117
114
  scrollToEnd(behavior?: ScrollBehavior): void;
118
115
  ngAfterViewInit(): void;
119
116
  ngOnDestroy(): void;
package/lib/types/id.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Identifier type
3
- * @link https://github.com/DjonnyX/ng-virtual-list/blob/main/projects/ng-virtual-list/src/lib/types/id.ts
3
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/types/id.ts
4
4
  * @author Evgenii Grebennikov
5
5
  * @email djonnyx@gmail.com
6
6
  */
@@ -1,7 +1,7 @@
1
1
  import { ISize } from "./size";
2
2
  /**
3
3
  * Rectangular area interface
4
- * @link https://github.com/DjonnyX/ng-virtual-list/blob/main/projects/ng-virtual-list/src/lib/types/rect.ts
4
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/types/rect.ts
5
5
  * @author Evgenii Grebennikov
6
6
  * @email djonnyx@gmail.com
7
7
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Area area Interface
3
- * @link https://github.com/DjonnyX/ng-virtual-list/blob/main/projects/ng-virtual-list/src/lib/types/size.ts
3
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/types/size.ts
4
4
  * @author Evgenii Grebennikov
5
5
  * @email djonnyx@gmail.com
6
6
  */
@@ -1,3 +1,4 @@
1
+ import { ScrollDirection } from "../models";
1
2
  import { EventEmitter } from "./eventEmitter";
2
3
  export interface ICacheMap<I = any, B = any> {
3
4
  set: (id: I, bounds: B) => Map<I, B>;
@@ -11,7 +12,7 @@ type CacheMapListeners = OnChangeEventListener;
11
12
  /**
12
13
  * Cache map.
13
14
  * Emits a change event on each mutation.
14
- * @link https://github.com/DjonnyX/ng-virtual-list/blob/main/projects/ng-virtual-list/src/lib/utils/cacheMap.ts
15
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/utils/cacheMap.ts
15
16
  * @author Evgenii Grebennikov
16
17
  * @email djonnyx@gmail.com
17
18
  */
@@ -21,8 +22,17 @@ export declare class CacheMap<I = string | number, B = any, E = CacheMapEvents,
21
22
  protected _previouseFullHeigh: number;
22
23
  protected _delta: number;
23
24
  get delta(): number;
25
+ protected _deltaDirection: ScrollDirection;
26
+ set deltaDirection(v: ScrollDirection);
27
+ get deltaDirection(): ScrollDirection;
28
+ private _scrollDirectionCache;
29
+ private _scrollDirection;
30
+ get scrollDirection(): ScrollDirection;
24
31
  get version(): number;
32
+ private _clearScrollDirectionDebounce;
25
33
  constructor();
34
+ clearScrollDirectionCache(): void;
35
+ private calcScrollDirection;
26
36
  protected bumpVersion(): void;
27
37
  protected fireChange(): void;
28
38
  set(id: I, bounds: B): Map<I, B>;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Simple debounce function.
3
- * @link https://github.com/DjonnyX/ng-virtual-list/blob/main/projects/ng-virtual-list/src/lib/utils/debounce.ts
3
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/utils/debounce.ts
4
4
  * @author Evgenii Grebennikov
5
5
  * @email djonnyx@gmail.com
6
6
  */
@@ -1,7 +1,7 @@
1
1
  export type TEventHandler = (...args: Array<any>) => void;
2
2
  /**
3
3
  * Simple event emitter
4
- * @link https://github.com/DjonnyX/ng-virtual-list/blob/main/projects/ng-virtual-list/src/lib/utils/eventEmitter.ts
4
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/utils/eventEmitter.ts
5
5
  * @author Evgenii Grebennikov
6
6
  * @email djonnyx@gmail.com
7
7
  */
@@ -1,7 +1,7 @@
1
1
  import { Direction } from "../enums";
2
2
  /**
3
3
  * Determines the axis membership of a virtual list
4
- * @link https://github.com/DjonnyX/ng-virtual-list/blob/main/projects/ng-virtual-list/src/lib/utils/isDirection.ts
4
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/utils/isDirection.ts
5
5
  * @author Evgenii Grebennikov
6
6
  * @email djonnyx@gmail.com
7
7
  */
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Switch css classes
3
- * @link https://github.com/DjonnyX/ng-virtual-list/blob/main/projects/ng-virtual-list/src/lib/utils/toggleClassName.ts
3
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/utils/toggleClassName.ts
4
4
  * @author Evgenii Grebennikov
5
5
  * @email djonnyx@gmail.com
6
6
  */
@@ -40,7 +40,6 @@ export interface IMetrics {
40
40
  totalSize: number;
41
41
  typicalItemSize: number;
42
42
  }
43
- export type ScrollDirection = -1 | 0 | 1;
44
43
  export interface IRecalculateMetricsOptions<I extends {
45
44
  id: Id;
46
45
  }, C extends Array<I>> {
@@ -53,14 +52,13 @@ export interface IRecalculateMetricsOptions<I extends {
53
52
  scrollSize: number;
54
53
  snap: boolean;
55
54
  fromItemId?: Id;
56
- scrollDirection?: ScrollDirection;
57
55
  }
58
56
  type CacheMapEvents = typeof TRACK_BOX_CHANGE_EVENT_NAME;
59
57
  type OnChangeEventListener = (version: number) => void;
60
58
  type CacheMapListeners = OnChangeEventListener;
61
59
  /**
62
60
  * An object that performs tracking, calculations and caching.
63
- * @link https://github.com/DjonnyX/ng-virtual-list/blob/main/projects/ng-virtual-list/src/lib/utils/trackBox.ts
61
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/utils/trackBox.ts
64
62
  * @author Evgenii Grebennikov
65
63
  * @email djonnyx@gmail.com
66
64
  */
@@ -85,13 +83,15 @@ export declare class TrackBox extends CacheMap<Id, IRect, CacheMapEvents, CacheM
85
83
  totalSize: number;
86
84
  delta: number;
87
85
  };
86
+ private getElementNumToEnd;
88
87
  /**
89
88
  * Calculates list metrics
90
89
  */
91
90
  protected recalculateMetrics<I extends {
92
91
  id: Id;
93
92
  }, C extends Array<I>>(options: IRecalculateMetricsOptions<I, C>): IMetrics;
94
- clearDelta(): void;
93
+ clearDeltaDirection(): void;
94
+ clearDelta(clearDirectionDetector?: boolean): void;
95
95
  protected generateDisplayCollection<I extends {
96
96
  id: Id;
97
97
  }, C extends Array<I>>(items: C, stickyMap: IVirtualListStickyMap, metrics: IMetrics): IRenderVirtualListCollection;
@@ -1,7 +1,7 @@
1
1
  import { ComponentRef } from "@angular/core";
2
2
  /**
3
3
  * Tracks display items by property
4
- * @link https://github.com/DjonnyX/ng-virtual-list/blob/main/projects/ng-virtual-list/src/lib/utils/tracker.ts
4
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/17.x/projects/ng-virtual-list/src/lib/utils/tracker.ts
5
5
  * @author Evgenii Grebennikov
6
6
  * @email djonnyx@gmail.com
7
7
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ng-virtual-list",
3
- "version": "17.0.0",
3
+ "version": "17.0.2",
4
4
  "author": {
5
5
  "name": "Evgenii Grebennikov",
6
6
  "email": "djonnyx@gmail.com"