ng-virtual-list 20.1.0 → 20.1.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.
- package/README.md +8 -7
- package/fesm2022/ng-virtual-list.mjs +24 -15
- package/fesm2022/ng-virtual-list.mjs.map +1 -1
- package/index.d.ts +3 -427
- package/lib/components/ng-virtual-list-item.component.d.ts +34 -0
- package/lib/const/index.d.ts +41 -0
- package/lib/enums/direction.d.ts +8 -0
- package/lib/enums/directions.d.ts +16 -0
- package/lib/enums/index.d.ts +7 -0
- package/lib/enums/snapping-method.d.ts +10 -0
- package/lib/enums/snapping-methods.d.ts +16 -0
- package/lib/models/collection.model.d.ts +9 -0
- package/lib/models/index.d.ts +6 -0
- package/lib/models/item.model.d.ts +14 -0
- package/lib/models/render-collection.model.d.ts +9 -0
- package/lib/models/render-item-config.model.d.ts +37 -0
- package/lib/models/render-item.model.d.ts +33 -0
- package/lib/models/scroll-direction.model.d.ts +5 -0
- package/lib/models/scroll-event.model.d.ts +50 -0
- package/lib/models/sticky-map.model.d.ts +12 -0
- package/lib/ng-virtual-list.component.d.ts +143 -0
- package/lib/types/id.d.ts +7 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/rect.d.ts +17 -0
- package/lib/types/size.d.ts +16 -0
- package/lib/utils/browser.d.ts +2 -0
- package/lib/utils/cacheMap.d.ts +60 -0
- package/lib/utils/debounce.d.ts +16 -0
- package/lib/utils/eventEmitter.d.ts +40 -0
- package/lib/utils/index.d.ts +7 -0
- package/lib/utils/isDirection.d.ts +8 -0
- package/lib/utils/scrollEvent.d.ts +39 -0
- package/lib/utils/snapping-method.d.ts +3 -0
- package/lib/utils/toggleClassName.d.ts +7 -0
- package/lib/utils/trackBox.d.ts +180 -0
- package/lib/utils/tracker.d.ts +44 -0
- package/package.json +1 -1
- package/public-api.d.ts +4 -0
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# NgVirtualList
|
|
2
2
|
|
|
3
|
-
Maximum performance for extremely large lists
|
|
3
|
+
Maximum performance for extremely large lists.<br/>
|
|
4
|
+
Animation of elements is supported.
|
|
4
5
|
|
|
5
6
|
<img width="1033" height="171" alt="logo" src="https://github.com/user-attachments/assets/b559cfde-405a-4361-b71b-6715478d997d" />
|
|
6
7
|
|
|
@@ -487,12 +488,12 @@ Methods
|
|
|
487
488
|
|
|
488
489
|
| Angular version | ng-virtual-list version | git | npm |
|
|
489
490
|
|--|--|--|--|
|
|
490
|
-
| 19.x | 19.2.
|
|
491
|
-
| 18.x | 18.1.
|
|
492
|
-
| 17.x | 17.1.
|
|
493
|
-
| 16.x | 16.1.
|
|
494
|
-
| 15.x | 15.1.
|
|
495
|
-
| 14.x | 14.1.
|
|
491
|
+
| 19.x | 19.2.5 | [19.x](https://github.com/DjonnyX/ng-virtual-list/tree/19.x) | [19.2.5](https://www.npmjs.com/package/ng-virtual-list/v/19.2.5) |
|
|
492
|
+
| 18.x | 18.1.2 | [18.x](https://github.com/DjonnyX/ng-virtual-list/tree/18.x) | [18.1.2](https://www.npmjs.com/package/ng-virtual-list/v/18.1.2) |
|
|
493
|
+
| 17.x | 17.1.2 | [17.x](https://github.com/DjonnyX/ng-virtual-list/tree/17.x) | [17.1.2](https://www.npmjs.com/package/ng-virtual-list/v/17.1.2) |
|
|
494
|
+
| 16.x | 16.1.2 | [16.x](https://github.com/DjonnyX/ng-virtual-list/tree/16.x) | [16.1.2](https://www.npmjs.com/package/ng-virtual-list/v/16.1.2) |
|
|
495
|
+
| 15.x | 15.1.2 | [15.x](https://github.com/DjonnyX/ng-virtual-list/tree/15.x) | [15.1.2](https://www.npmjs.com/package/ng-virtual-list/v/15.1.2) |
|
|
496
|
+
| 14.x | 14.1.2 | [14.x](https://github.com/DjonnyX/ng-virtual-list/tree/14.x) | [14.1.2](https://www.npmjs.com/package/ng-virtual-list/v/14.1.2) |
|
|
496
497
|
|
|
497
498
|
<br/>
|
|
498
499
|
|
|
@@ -193,10 +193,10 @@ class NgVirtualListItemComponent {
|
|
|
193
193
|
styles.transform = ZEROS_TRANSLATE_3D;
|
|
194
194
|
styles.zIndex = HIDDEN_ZINDEX;
|
|
195
195
|
}
|
|
196
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
197
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
196
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgVirtualListItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
197
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: NgVirtualListItemComponent, isStandalone: true, selector: "ng-virtual-list-item", host: { classAttribute: "ngvl__item" }, ngImport: i0, template: "@let item = data();\r\n@let renderer = itemRenderer();\r\n\r\n@if (item) {\r\n <li #listItem part=\"item\" class=\"ngvl-item__container\" [ngClass]=\"{'snapped': item.config.snapped,\r\n 'snapped-out': item.config.snappedOut}\">\r\n @if (renderer) {\r\n <ng-container [ngTemplateOutlet]=\"renderer\"\r\n [ngTemplateOutletContext]=\"{data: item.data || {}, config: item.config}\" />\r\n }\r\n </li>\r\n}", 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: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
198
198
|
}
|
|
199
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
199
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgVirtualListItemComponent, decorators: [{
|
|
200
200
|
type: Component,
|
|
201
201
|
args: [{ selector: 'ng-virtual-list-item', imports: [CommonModule], host: {
|
|
202
202
|
'class': 'ngvl__item',
|
|
@@ -1344,6 +1344,9 @@ const isSnappingMethodDefault = (method) => {
|
|
|
1344
1344
|
return DEFAULT_PATTERN.includes(method);
|
|
1345
1345
|
};
|
|
1346
1346
|
|
|
1347
|
+
const IS_FIREFOX = navigator.userAgent.toLowerCase().includes('firefox');
|
|
1348
|
+
const FIREFOX_SCROLLBAR_OVERLAP_SIZE = 12;
|
|
1349
|
+
|
|
1347
1350
|
/**
|
|
1348
1351
|
* Virtual list component.
|
|
1349
1352
|
* Maximum performance for extremely large lists.
|
|
@@ -1447,13 +1450,20 @@ class NgVirtualListComponent {
|
|
|
1447
1450
|
_resizeSnappedComponentHandler = () => {
|
|
1448
1451
|
const list = this._list(), container = this._container(), snappedComponent = this._snapedDisplayComponent?.instance;
|
|
1449
1452
|
if (list && container && snappedComponent) {
|
|
1450
|
-
const isVertical = this._isVertical, listBounds = list.nativeElement.getBoundingClientRect();
|
|
1453
|
+
const isVertical = this._isVertical, listBounds = list.nativeElement.getBoundingClientRect(), listElement = list?.nativeElement, { width: lWidth, height: lHeight } = listElement?.getBoundingClientRect() ?? { width: 0, height: 0 }, { width, height } = this._bounds() ?? { width: 0, height: 0 }, isScrollable = isVertical ? container.nativeElement.scrollHeight > 0 : container.nativeElement.scrollWidth > 0;
|
|
1454
|
+
let scrollBarSize = isVertical ? width - lWidth : height - lHeight, isScrollBarOverlap = true, overlapScrollBarSize = 0;
|
|
1455
|
+
if (scrollBarSize === 0 && isScrollable) {
|
|
1456
|
+
isScrollBarOverlap = true;
|
|
1457
|
+
}
|
|
1458
|
+
if (isScrollBarOverlap && IS_FIREFOX) {
|
|
1459
|
+
scrollBarSize = overlapScrollBarSize = FIREFOX_SCROLLBAR_OVERLAP_SIZE;
|
|
1460
|
+
}
|
|
1461
|
+
snappedComponent.element.style.clipPath = `path("M 0 0 L 0 ${snappedComponent.element.offsetHeight} L ${snappedComponent.element.offsetWidth - overlapScrollBarSize} ${snappedComponent.element.offsetHeight} L ${snappedComponent.element.offsetWidth - overlapScrollBarSize} 0 Z")`;
|
|
1451
1462
|
snappedComponent.regularLength = `${isVertical ? listBounds.width : listBounds.height}${PX}`;
|
|
1452
|
-
const { width: sWidth, height: sHeight } = snappedComponent.getBounds() ?? { width: 0, height: 0 }, containerElement = container.nativeElement
|
|
1453
|
-
let left, right, top, bottom
|
|
1463
|
+
const { width: sWidth, height: sHeight } = snappedComponent.getBounds() ?? { width: 0, height: 0 }, containerElement = container.nativeElement;
|
|
1464
|
+
let left, right, top, bottom;
|
|
1454
1465
|
if (isVertical) {
|
|
1455
1466
|
const snappedY = snappedComponent.item?.measures.y ?? 0, scrollSize = container.nativeElement.scrollTop, delta = snappedY - scrollSize;
|
|
1456
|
-
scrollBarSize = width - lWidth;
|
|
1457
1467
|
left = 0;
|
|
1458
1468
|
right = width - scrollBarSize;
|
|
1459
1469
|
top = sHeight;
|
|
@@ -1462,7 +1472,6 @@ class NgVirtualListComponent {
|
|
|
1462
1472
|
}
|
|
1463
1473
|
else {
|
|
1464
1474
|
const snappedX = snappedComponent.item?.measures.x ?? 0, scrollSize = container.nativeElement.scrollLeft, delta = snappedX - scrollSize;
|
|
1465
|
-
scrollBarSize = height - lHeight;
|
|
1466
1475
|
left = sWidth;
|
|
1467
1476
|
right = width;
|
|
1468
1477
|
top = 0;
|
|
@@ -1776,15 +1785,15 @@ class NgVirtualListComponent {
|
|
|
1776
1785
|
if (this._resizeObserver) {
|
|
1777
1786
|
this._resizeObserver.disconnect();
|
|
1778
1787
|
}
|
|
1779
|
-
if (this._snapedDisplayComponent) {
|
|
1780
|
-
this._snapedDisplayComponent.destroy();
|
|
1781
|
-
}
|
|
1782
1788
|
const containerEl = this._container();
|
|
1783
1789
|
if (containerEl) {
|
|
1784
1790
|
containerEl.nativeElement.removeEventListener(SCROLL, this._onScrollHandler);
|
|
1785
1791
|
containerEl.nativeElement.removeEventListener(SCROLL, this._onContainerScrollHandler);
|
|
1786
1792
|
containerEl.nativeElement.removeEventListener(SCROLL_END, this._onContainerScrollEndHandler);
|
|
1787
1793
|
}
|
|
1794
|
+
if (this._snapedDisplayComponent) {
|
|
1795
|
+
this._snapedDisplayComponent.destroy();
|
|
1796
|
+
}
|
|
1788
1797
|
if (this._displayComponents) {
|
|
1789
1798
|
while (this._displayComponents.length > 0) {
|
|
1790
1799
|
const comp = this._displayComponents.pop();
|
|
@@ -1792,12 +1801,12 @@ class NgVirtualListComponent {
|
|
|
1792
1801
|
}
|
|
1793
1802
|
}
|
|
1794
1803
|
}
|
|
1795
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1796
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
1804
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgVirtualListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1805
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.14", type: NgVirtualListComponent, isStandalone: true, selector: "ng-virtual-list", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: true, transformFunction: null }, snap: { classPropertyName: "snap", publicName: "snap", isSignal: true, isRequired: false, transformFunction: null }, enabledBufferOptimization: { classPropertyName: "enabledBufferOptimization", publicName: "enabledBufferOptimization", isSignal: true, isRequired: false, transformFunction: null }, itemRenderer: { classPropertyName: "itemRenderer", publicName: "itemRenderer", isSignal: true, isRequired: true, transformFunction: null }, stickyMap: { classPropertyName: "stickyMap", publicName: "stickyMap", isSignal: true, isRequired: false, transformFunction: null }, itemSize: { classPropertyName: "itemSize", publicName: "itemSize", isSignal: true, isRequired: false, transformFunction: null }, dynamicSize: { classPropertyName: "dynamicSize", publicName: "dynamicSize", isSignal: true, isRequired: false, transformFunction: null }, direction: { classPropertyName: "direction", publicName: "direction", isSignal: true, isRequired: false, transformFunction: null }, itemsOffset: { classPropertyName: "itemsOffset", publicName: "itemsOffset", isSignal: true, isRequired: false, transformFunction: null }, snappingMethod: { classPropertyName: "snappingMethod", publicName: "snappingMethod", isSignal: true, isRequired: false, transformFunction: null }, trackBy: { classPropertyName: "trackBy", publicName: "trackBy", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { onScroll: "onScroll", onScrollEnd: "onScrollEnd" }, viewQueries: [{ propertyName: "_snappedContainer", first: true, predicate: ["snapped"], descendants: true, isSignal: true }, { propertyName: "_container", first: true, predicate: ["container"], descendants: true, isSignal: true }, { propertyName: "_list", first: true, predicate: ["list"], descendants: true, isSignal: true }, { propertyName: "_listContainerRef", first: true, predicate: ["renderersContainer"], descendants: true, read: ViewContainerRef }, { propertyName: "_snapContainerRef", first: true, predicate: ["snapRendererContainer"], descendants: true, read: ViewContainerRef }], ngImport: i0, template: "@if (snap()) {\r\n<div #snapped part=\"snapped-item\" class=\"ngvl__list-snapper\">\r\n <ng-container #snapRendererContainer></ng-container>\r\n</div>\r\n}\r\n<div #container part=\"scroller\" class=\"ngvl__scroller\">\r\n <ul #list part=\"list\" class=\"ngvl__list\">\r\n <ng-container #renderersContainer></ng-container>\r\n </ul>\r\n</div>", styles: [":host{position:relative;display:block;width:400px;overflow:hidden}:host(.horizontal){height:48px}:host(.vertical){height:320px}.ngvl__scroller{overflow:auto;width:100%;height:100%}.ngvl__list-snapper{pointer-events:none;position:absolute;list-style:none;left:0;top:0;z-index:1}.ngvl__list{position:relative;list-style:none;padding:0;margin:0;width:100%;height:100%}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.ShadowDom });
|
|
1797
1806
|
}
|
|
1798
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1807
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.14", ngImport: i0, type: NgVirtualListComponent, decorators: [{
|
|
1799
1808
|
type: Component,
|
|
1800
|
-
args: [{ selector: 'ng-virtual-list', imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.ShadowDom, template: "@if (snap()) {\r\n<div #snapped part=\"snapped-item\" class=\"ngvl__list-snapper\">\r\n <ng-container #snapRendererContainer></ng-container>\r\n</div>\r\n}\r\n<div #container part=\"scroller\" class=\"ngvl__scroller\">\r\n <ul #list part=\"list\" class=\"ngvl__list\">\r\n <ng-container #renderersContainer></ng-container>\r\n </ul>\r\n</div>", styles: [":host{position:relative;display:block;width:400px;overflow:hidden}:host(.horizontal){height:48px}:host(.vertical){height:320px}.ngvl__scroller{overflow:auto;width:100%;height:100%}.ngvl__list-snapper{position:absolute;list-style:none;left:0;top:0;z-index:1}.ngvl__list{position:relative;list-style:none;padding:0;margin:0;width:100%;height:100%}\n"] }]
|
|
1809
|
+
args: [{ selector: 'ng-virtual-list', imports: [CommonModule], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.ShadowDom, template: "@if (snap()) {\r\n<div #snapped part=\"snapped-item\" class=\"ngvl__list-snapper\">\r\n <ng-container #snapRendererContainer></ng-container>\r\n</div>\r\n}\r\n<div #container part=\"scroller\" class=\"ngvl__scroller\">\r\n <ul #list part=\"list\" class=\"ngvl__list\">\r\n <ng-container #renderersContainer></ng-container>\r\n </ul>\r\n</div>", styles: [":host{position:relative;display:block;width:400px;overflow:hidden}:host(.horizontal){height:48px}:host(.vertical){height:320px}.ngvl__scroller{overflow:auto;width:100%;height:100%}.ngvl__list-snapper{pointer-events:none;position:absolute;list-style:none;left:0;top:0;z-index:1}.ngvl__list{position:relative;list-style:none;padding:0;margin:0;width:100%;height:100%}\n"] }]
|
|
1801
1810
|
}], ctorParameters: () => [], propDecorators: { _listContainerRef: [{
|
|
1802
1811
|
type: ViewChild,
|
|
1803
1812
|
args: ['renderersContainer', { read: ViewContainerRef }]
|