ng-virtual-list 16.2.0 → 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.
@@ -82,13 +82,22 @@ const SCROLL_END = 'scrollend';
82
82
  const CLASS_LIST_VERTICAL = 'vertical';
83
83
  const CLASS_LIST_HORIZONTAL = 'horizontal';
84
84
 
85
+ /**
86
+ * Virtual List Item Interface
87
+ * @link https://github.com/DjonnyX/ng-virtual-list/blob/16.x/projects/ng-virtual-list/src/lib/models/base-virtual-list-item-component.ts
88
+ * @author Evgenii Grebennikov
89
+ * @email djonnyx@gmail.com
90
+ */
91
+ class BaseVirtualListItemComponent {
92
+ }
93
+
85
94
  /**
86
95
  * Virtual list item component
87
96
  * @link https://github.com/DjonnyX/ng-virtual-list/blob/16.x/projects/ng-virtual-list/src/lib/components/ng-virtual-list-item.component.ts
88
97
  * @author Evgenii Grebennikov
89
98
  * @email djonnyx@gmail.com
90
99
  */
91
- class NgVirtualListItemComponent {
100
+ class NgVirtualListItemComponent extends BaseVirtualListItemComponent {
92
101
  _cdr;
93
102
  _elementRef;
94
103
  static __nextId = 0;
@@ -133,6 +142,7 @@ class NgVirtualListItemComponent {
133
142
  return this._elementRef.nativeElement;
134
143
  }
135
144
  constructor(_cdr, _elementRef) {
145
+ super();
136
146
  this._cdr = _cdr;
137
147
  this._elementRef = _elementRef;
138
148
  this._id = NgVirtualListItemComponent.__nextId = NgVirtualListItemComponent.__nextId === Number.MAX_SAFE_INTEGER
@@ -203,7 +213,7 @@ class NgVirtualListItemComponent {
203
213
  styles.zIndex = HIDDEN_ZINDEX;
204
214
  }
205
215
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgVirtualListItemComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
206
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: NgVirtualListItemComponent, selector: "ng-virtual-list-item", host: { classAttribute: "ngvl__item" }, ngImport: i0, template: "<ng-container *ngIf=\"data\">\r\n <li #listItem part=\"item\" class=\"ngvl-item__container\" [ngClass]=\"{'snapped': data.config.snapped,\r\n 'snapped-out': data.config.snappedOut}\">\r\n <ng-container *ngIf=\"itemRenderer\">\r\n <ng-container [ngTemplateOutlet]=\"itemRenderer\"\r\n [ngTemplateOutletContext]=\"{data: data.data || {}, config: data.config}\" />\r\n </ng-container>\r\n </li>\r\n</ng-container>", styles: [":host{display:block;position:absolute;left:0;top:0;box-sizing:border-box;overflow:hidden}.ngvl-item__container{margin:0;padding:0;overflow:hidden;background-color:#fff;width:inherit;height:inherit}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
216
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: NgVirtualListItemComponent, selector: "ng-virtual-list-item", host: { classAttribute: "ngvl__item" }, usesInheritance: true, ngImport: i0, template: "<ng-container *ngIf=\"data\">\r\n <li #listItem part=\"item\" class=\"ngvl-item__container\" [ngClass]=\"{'snapped': data.config.snapped,\r\n 'snapped-out': data.config.snappedOut}\">\r\n <ng-container *ngIf=\"itemRenderer\">\r\n <ng-container [ngTemplateOutlet]=\"itemRenderer\"\r\n [ngTemplateOutletContext]=\"{data: data.data || {}, config: data.config}\" />\r\n </ng-container>\r\n </li>\r\n</ng-container>", styles: [":host{display:block;position:absolute;left:0;top:0;box-sizing:border-box;overflow:hidden}.ngvl-item__container{margin:0;padding:0;overflow:hidden;background-color:#fff;width:inherit;height:inherit}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
207
217
  }
208
218
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: NgVirtualListItemComponent, decorators: [{
209
219
  type: Component,
@@ -1517,6 +1527,7 @@ class NgVirtualListComponent {
1517
1527
  get enabledBufferOptimization() { return this._$enabledBufferOptimization.getValue(); }
1518
1528
  _$itemRenderer = new BehaviorSubject(undefined);
1519
1529
  $itemRenderer = this._$itemRenderer.asObservable();
1530
+ _$renderer = new BehaviorSubject(undefined);
1520
1531
  /**
1521
1532
  * Rendering element template.
1522
1533
  */
@@ -1699,10 +1710,18 @@ class NgVirtualListComponent {
1699
1710
  };
1700
1711
  _$initialized = new BehaviorSubject(false);
1701
1712
  $initialized;
1713
+ /**
1714
+ * Base class of the element component
1715
+ */
1716
+ _itemComponentClass = NgVirtualListItemComponent;
1717
+ /**
1718
+ * Base class trackBox
1719
+ */
1720
+ _trackBoxClass = TrackBox;
1702
1721
  /**
1703
1722
  * Dictionary of element sizes by their id
1704
1723
  */
1705
- _trackBox = new TrackBox(this.trackBy);
1724
+ _trackBox = new this._trackBoxClass(this.trackBy);
1706
1725
  _onTrackBoxChangeHandler = (v) => {
1707
1726
  this._$cacheVersion.next(v);
1708
1727
  };
@@ -1762,12 +1781,19 @@ class NgVirtualListComponent {
1762
1781
  }
1763
1782
  return of(displayItems);
1764
1783
  })).subscribe();
1765
- combineLatest([this.$initialized, this.$itemRenderer]).pipe(takeUntilDestroyed(), distinctUntilChanged(), filter(([initialized]) => !!initialized), tap(([, itemRenderer]) => {
1766
- this.resetRenderers(itemRenderer);
1767
- }));
1784
+ this.setupRenderer();
1785
+ }
1786
+ setupRenderer() {
1787
+ const $itemRenderer = this.$itemRenderer;
1788
+ $itemRenderer.pipe(takeUntilDestroyed(), distinctUntilChanged(), filter(v => !!v), tap(v => {
1789
+ this._$renderer.next(v);
1790
+ })).subscribe();
1768
1791
  }
1769
1792
  /** @internal */
1770
1793
  ngOnInit() {
1794
+ this.onInit();
1795
+ }
1796
+ onInit() {
1771
1797
  this._$initialized.next(true);
1772
1798
  }
1773
1799
  listenCacheChangesIfNeed(value) {
@@ -1800,7 +1826,7 @@ class NgVirtualListComponent {
1800
1826
  }
1801
1827
  if (this._isSnappingMethodAdvanced && this.snap) {
1802
1828
  if (!this._snapedDisplayComponent && this._snapContainerRef) {
1803
- const comp = this._snapContainerRef.createComponent(NgVirtualListItemComponent);
1829
+ const comp = this._snapContainerRef.createComponent(this._itemComponentClass);
1804
1830
  comp.instance.regular = true;
1805
1831
  this._snapedDisplayComponent = comp;
1806
1832
  this._trackBox.snapedDisplayComponent = this._snapedDisplayComponent;
@@ -1813,7 +1839,7 @@ class NgVirtualListComponent {
1813
1839
  const maxLength = displayItems.length, components = this._displayComponents;
1814
1840
  while (components.length < maxLength) {
1815
1841
  if (_listContainerRef) {
1816
- const comp = _listContainerRef.createComponent(NgVirtualListItemComponent);
1842
+ const comp = _listContainerRef.createComponent(this._itemComponentClass);
1817
1843
  components.push(comp);
1818
1844
  this._componentsResizeObserver.observe(comp.instance.element);
1819
1845
  }
@@ -1950,6 +1976,9 @@ class NgVirtualListComponent {
1950
1976
  };
1951
1977
  /** @internal */
1952
1978
  ngAfterViewInit() {
1979
+ this.afterViewInit();
1980
+ }
1981
+ afterViewInit() {
1953
1982
  const containerEl = this._container;
1954
1983
  if (containerEl) {
1955
1984
  // for direction calculation
@@ -1963,6 +1992,9 @@ class NgVirtualListComponent {
1963
1992
  }
1964
1993
  /** @internal */
1965
1994
  ngOnDestroy() {
1995
+ this.dispose();
1996
+ }
1997
+ dispose() {
1966
1998
  this.clearScrollToRepeatExecutionTimeout();
1967
1999
  if (this._trackBox) {
1968
2000
  this._trackBox.dispose();
@@ -2064,5 +2096,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImpo
2064
2096
  * Generated bundle index. Do not edit.
2065
2097
  */
2066
2098
 
2067
- export { Directions, NgVirtualListComponent, NgVirtualListModule, SnappingMethods };
2099
+ export { BaseVirtualListItemComponent, Directions, NgVirtualListComponent, NgVirtualListItemComponent, NgVirtualListModule, SnappingMethods };
2068
2100
  //# sourceMappingURL=ng-virtual-list.mjs.map