ng-virtual-list 14.2.0 → 14.3.1
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/README.md +4 -4
- package/esm2020/lib/components/ng-virtual-list-item.component.mjs +5 -3
- package/esm2020/lib/enums/direction.mjs +1 -1
- package/esm2020/lib/models/base-virtual-list-item-component.mjs +9 -0
- package/esm2020/lib/models/collection.model.mjs +1 -1
- package/esm2020/lib/models/component.model.mjs +2 -0
- package/esm2020/lib/models/index.mjs +3 -2
- package/esm2020/lib/models/item.model.mjs +1 -2
- package/esm2020/lib/ng-virtual-list.component.mjs +30 -8
- package/esm2020/lib/utils/index.mjs +4 -3
- package/esm2020/lib/utils/trackBox.mjs +6 -3
- package/esm2020/lib/utils/tracker.mjs +1 -1
- package/esm2020/public-api.mjs +2 -1
- package/fesm2015/ng-virtual-list.mjs +45 -10
- package/fesm2015/ng-virtual-list.mjs.map +1 -1
- package/fesm2020/ng-virtual-list.mjs +45 -10
- package/fesm2020/ng-virtual-list.mjs.map +1 -1
- package/lib/components/ng-virtual-list-item.component.d.ts +7 -6
- package/lib/enums/direction.d.ts +1 -1
- package/lib/models/base-virtual-list-item-component.d.ts +25 -0
- package/lib/models/collection.model.d.ts +1 -1
- package/lib/models/component.model.d.ts +3 -0
- package/lib/models/index.d.ts +4 -1
- package/lib/models/item.model.d.ts +2 -2
- package/lib/ng-virtual-list.component.d.ts +58 -44
- package/lib/utils/index.d.ts +4 -2
- package/lib/utils/trackBox.d.ts +30 -22
- package/lib/utils/tracker.d.ts +7 -5
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
|
@@ -81,14 +81,24 @@ const SCROLL_END = 'scrollend';
|
|
|
81
81
|
const CLASS_LIST_VERTICAL = 'vertical';
|
|
82
82
|
const CLASS_LIST_HORIZONTAL = 'horizontal';
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* Virtual List Item Interface
|
|
86
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/14.x/projects/ng-virtual-list/src/lib/models/base-virtual-list-item-component.ts
|
|
87
|
+
* @author Evgenii Grebennikov
|
|
88
|
+
* @email djonnyx@gmail.com
|
|
89
|
+
*/
|
|
90
|
+
class BaseVirtualListItemComponent {
|
|
91
|
+
}
|
|
92
|
+
|
|
84
93
|
/**
|
|
85
94
|
* Virtual list item component
|
|
86
95
|
* @link https://github.com/DjonnyX/ng-virtual-list/blob/14.x/projects/ng-virtual-list/src/lib/components/ng-virtual-list-item.component.ts
|
|
87
96
|
* @author Evgenii Grebennikov
|
|
88
97
|
* @email djonnyx@gmail.com
|
|
89
98
|
*/
|
|
90
|
-
class NgVirtualListItemComponent {
|
|
99
|
+
class NgVirtualListItemComponent extends BaseVirtualListItemComponent {
|
|
91
100
|
constructor(_cdr, _elementRef) {
|
|
101
|
+
super();
|
|
92
102
|
this._cdr = _cdr;
|
|
93
103
|
this._elementRef = _elementRef;
|
|
94
104
|
this.regular = false;
|
|
@@ -198,7 +208,7 @@ class NgVirtualListItemComponent {
|
|
|
198
208
|
}
|
|
199
209
|
NgVirtualListItemComponent.__nextId = 0;
|
|
200
210
|
NgVirtualListItemComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgVirtualListItemComponent, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.ElementRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
201
|
-
NgVirtualListItemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", 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}\"></ng-container>\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;will-change:scroll-position}.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 });
|
|
211
|
+
NgVirtualListItemComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.3.0", 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}\"></ng-container>\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;will-change:scroll-position}.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 });
|
|
202
212
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: NgVirtualListItemComponent, decorators: [{
|
|
203
213
|
type: Component,
|
|
204
214
|
args: [{ selector: 'ng-virtual-list-item', host: {
|
|
@@ -1098,7 +1108,7 @@ class TrackBox extends CacheMap {
|
|
|
1098
1108
|
}
|
|
1099
1109
|
}
|
|
1100
1110
|
if (deletedItemsMap.hasOwnProperty(i)) {
|
|
1101
|
-
const bounds = deletedItemsMap[i], size = bounds[sizeProperty] ?? typicalItemSize;
|
|
1111
|
+
const bounds = deletedItemsMap[i], size = bounds?.[sizeProperty] ?? typicalItemSize;
|
|
1102
1112
|
if (y < scrollSize - size) {
|
|
1103
1113
|
leftSizeOfDeletedItems += size;
|
|
1104
1114
|
}
|
|
@@ -1189,6 +1199,9 @@ class TrackBox extends CacheMap {
|
|
|
1189
1199
|
let pos = startPosition, renderItems = renderItemsLength, stickyItem, nextSticky, stickyItemIndex = -1, stickyItemSize = 0, endStickyItem, nextEndSticky, endStickyItemIndex = -1, endStickyItemSize = 0;
|
|
1190
1200
|
if (snap) {
|
|
1191
1201
|
for (let i = Math.min(itemsFromStartToScrollEnd > 0 ? itemsFromStartToScrollEnd : 0, totalLength - 1); i >= 0; i--) {
|
|
1202
|
+
if (!items[i]) {
|
|
1203
|
+
continue;
|
|
1204
|
+
}
|
|
1192
1205
|
const id = items[i].id, sticky = stickyMap[id], size = dynamicSize ? this.get(id)?.[sizeProperty] || typicalItemSize : typicalItemSize;
|
|
1193
1206
|
if (sticky === 1) {
|
|
1194
1207
|
const measures = {
|
|
@@ -1483,6 +1496,7 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
1483
1496
|
this.$enabledBufferOptimization = this._$enabledBufferOptimization.asObservable();
|
|
1484
1497
|
this._$itemRenderer = new BehaviorSubject(undefined);
|
|
1485
1498
|
this.$itemRenderer = this._$itemRenderer.asObservable();
|
|
1499
|
+
this._$renderer = new BehaviorSubject(undefined);
|
|
1486
1500
|
this._$stickyMap = new BehaviorSubject({});
|
|
1487
1501
|
this.$stickyMap = this._$stickyMap.asObservable();
|
|
1488
1502
|
this._itemSizeOptions = (v) => {
|
|
@@ -1564,10 +1578,18 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
1564
1578
|
}
|
|
1565
1579
|
};
|
|
1566
1580
|
this._$initialized = new BehaviorSubject(false);
|
|
1581
|
+
/**
|
|
1582
|
+
* Base class of the element component
|
|
1583
|
+
*/
|
|
1584
|
+
this._itemComponentClass = NgVirtualListItemComponent;
|
|
1585
|
+
/**
|
|
1586
|
+
* Base class trackBox
|
|
1587
|
+
*/
|
|
1588
|
+
this._trackBoxClass = TrackBox;
|
|
1567
1589
|
/**
|
|
1568
1590
|
* Dictionary of element sizes by their id
|
|
1569
1591
|
*/
|
|
1570
|
-
this._trackBox = new
|
|
1592
|
+
this._trackBox = new this._trackBoxClass(this.trackBy);
|
|
1571
1593
|
this._onTrackBoxChangeHandler = (v) => {
|
|
1572
1594
|
this._$cacheVersion.next(v);
|
|
1573
1595
|
};
|
|
@@ -1652,9 +1674,7 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
1652
1674
|
}
|
|
1653
1675
|
return of(displayItems);
|
|
1654
1676
|
})).subscribe();
|
|
1655
|
-
|
|
1656
|
-
this.resetRenderers(itemRenderer);
|
|
1657
|
-
}));
|
|
1677
|
+
this.setupRenderer();
|
|
1658
1678
|
}
|
|
1659
1679
|
/**
|
|
1660
1680
|
* Readonly. Returns the unique identifier of the component.
|
|
@@ -1800,8 +1820,17 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
1800
1820
|
get snappingMethod() { return this._$snappingMethod.getValue(); }
|
|
1801
1821
|
get isSnappingMethodAdvanced() { return this._isSnappingMethodAdvanced; }
|
|
1802
1822
|
get $cacheVersion() { return this._$cacheVersion.asObservable(); }
|
|
1823
|
+
setupRenderer() {
|
|
1824
|
+
const $itemRenderer = this.$itemRenderer;
|
|
1825
|
+
$itemRenderer.pipe(takeUntil(this._$unsubscribe), distinctUntilChanged(), filter(v => !!v), tap(v => {
|
|
1826
|
+
this._$renderer.next(v);
|
|
1827
|
+
})).subscribe();
|
|
1828
|
+
}
|
|
1803
1829
|
/** @internal */
|
|
1804
1830
|
ngOnInit() {
|
|
1831
|
+
this.onInit();
|
|
1832
|
+
}
|
|
1833
|
+
onInit() {
|
|
1805
1834
|
this._$initialized.next(true);
|
|
1806
1835
|
}
|
|
1807
1836
|
listenCacheChangesIfNeed(value) {
|
|
@@ -1831,7 +1860,7 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
1831
1860
|
}
|
|
1832
1861
|
if (this._isSnappingMethodAdvanced && this.snap) {
|
|
1833
1862
|
if (!this._snapedDisplayComponent && this._snapContainerRef) {
|
|
1834
|
-
const comp = this._snapContainerRef.createComponent(
|
|
1863
|
+
const comp = this._snapContainerRef.createComponent(this._itemComponentClass);
|
|
1835
1864
|
comp.instance.regular = true;
|
|
1836
1865
|
this._snapedDisplayComponent = comp;
|
|
1837
1866
|
this._trackBox.snapedDisplayComponent = this._snapedDisplayComponent;
|
|
@@ -1844,7 +1873,7 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
1844
1873
|
const maxLength = displayItems.length, components = this._displayComponents;
|
|
1845
1874
|
while (components.length < maxLength) {
|
|
1846
1875
|
if (_listContainerRef) {
|
|
1847
|
-
const comp = _listContainerRef.createComponent(
|
|
1876
|
+
const comp = _listContainerRef.createComponent(this._itemComponentClass);
|
|
1848
1877
|
components.push(comp);
|
|
1849
1878
|
this._componentsResizeObserver.observe(comp.instance.element);
|
|
1850
1879
|
}
|
|
@@ -1954,6 +1983,9 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
1954
1983
|
}
|
|
1955
1984
|
/** @internal */
|
|
1956
1985
|
ngAfterViewInit() {
|
|
1986
|
+
this.afterViewInit();
|
|
1987
|
+
}
|
|
1988
|
+
afterViewInit() {
|
|
1957
1989
|
const containerEl = this._container;
|
|
1958
1990
|
if (containerEl) {
|
|
1959
1991
|
// for direction calculation
|
|
@@ -1968,6 +2000,9 @@ class NgVirtualListComponent extends DisposableComponent {
|
|
|
1968
2000
|
/** @internal */
|
|
1969
2001
|
ngOnDestroy() {
|
|
1970
2002
|
super.ngOnDestroy();
|
|
2003
|
+
this.dispose();
|
|
2004
|
+
}
|
|
2005
|
+
dispose() {
|
|
1971
2006
|
this.clearScrollToRepeatExecutionTimeout();
|
|
1972
2007
|
if (this._trackBox) {
|
|
1973
2008
|
this._trackBox.dispose();
|
|
@@ -2070,5 +2105,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.3.0", ngImpor
|
|
|
2070
2105
|
* Generated bundle index. Do not edit.
|
|
2071
2106
|
*/
|
|
2072
2107
|
|
|
2073
|
-
export { Directions, NgVirtualListComponent, NgVirtualListModule, SnappingMethods };
|
|
2108
|
+
export { BaseVirtualListItemComponent, Directions, NgVirtualListComponent, NgVirtualListItemComponent, NgVirtualListModule, SnappingMethods };
|
|
2074
2109
|
//# sourceMappingURL=ng-virtual-list.mjs.map
|