ng-virtual-list 20.0.30 → 20.0.32
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 +6 -6
- package/ng-package.json +7 -0
- package/package.json +29 -40
- package/src/lib/components/ng-virtual-list-item.component.html +12 -0
- package/src/lib/components/ng-virtual-list-item.component.scss +17 -0
- package/src/lib/components/ng-virtual-list-item.component.spec.ts +23 -0
- package/src/lib/components/ng-virtual-list-item.component.ts +108 -0
- package/src/lib/const/index.ts +67 -0
- package/src/lib/enums/direction.ts +9 -0
- package/src/lib/enums/directions.ts +16 -0
- package/src/lib/enums/index.ts +7 -0
- package/src/lib/models/collection.model.ts +9 -0
- package/src/lib/models/index.ts +13 -0
- package/src/lib/models/item.model.ts +15 -0
- package/src/lib/models/render-collection.model.ts +9 -0
- package/src/lib/models/render-item-config.model.ts +33 -0
- package/src/lib/models/render-item.model.ts +29 -0
- package/src/lib/models/scroll-direction.model.ts +5 -0
- package/src/lib/models/scroll-event.model.ts +51 -0
- package/src/lib/models/sticky-map.model.ts +12 -0
- package/src/lib/ng-virtual-list.component.html +5 -0
- package/src/lib/ng-virtual-list.component.scss +28 -0
- package/src/lib/ng-virtual-list.component.spec.ts +23 -0
- package/src/lib/ng-virtual-list.component.ts +543 -0
- package/src/lib/types/id.ts +7 -0
- package/src/lib/types/index.ts +9 -0
- package/src/lib/types/rect.ts +18 -0
- package/src/lib/types/size.ts +16 -0
- package/src/lib/utils/cacheMap.ts +223 -0
- package/src/lib/utils/debounce.ts +31 -0
- package/src/lib/utils/eventEmitter.ts +119 -0
- package/src/lib/utils/index.ts +15 -0
- package/src/lib/utils/isDirection.ts +17 -0
- package/src/lib/utils/scrollEvent.ts +62 -0
- package/src/lib/utils/toggleClassName.ts +14 -0
- package/src/lib/utils/trackBox.ts +839 -0
- package/src/lib/utils/tracker.ts +126 -0
- package/src/public-api.ts +7 -0
- package/tsconfig.lib.json +16 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +15 -0
- package/fesm2022/ng-virtual-list.mjs +0 -1618
- package/fesm2022/ng-virtual-list.mjs.map +0 -1
- package/index.d.ts +0 -378
package/README.md
CHANGED
|
@@ -479,12 +479,12 @@ Methods
|
|
|
479
479
|
|
|
480
480
|
| Angular version | ng-virtual-list version | git | npm |
|
|
481
481
|
|--|--|--|--|
|
|
482
|
-
| 19.x | 19.1.
|
|
483
|
-
| 18.x | 18.0.
|
|
484
|
-
| 17.x | 17.0.
|
|
485
|
-
| 16.x | 16.0.
|
|
486
|
-
| 15.x | 15.0.
|
|
487
|
-
| 14.x | 14.0.
|
|
482
|
+
| 19.x | 19.1.40 | [19.x](https://github.com/DjonnyX/ng-virtual-list/tree/19.x) | [19.1.40](https://www.npmjs.com/package/ng-virtual-list/v/19.1.40) |
|
|
483
|
+
| 18.x | 18.0.24 | [18.x](https://github.com/DjonnyX/ng-virtual-list/tree/18.x) | [18.0.24](https://www.npmjs.com/package/ng-virtual-list/v/18.0.24) |
|
|
484
|
+
| 17.x | 17.0.22 | [17.x](https://github.com/DjonnyX/ng-virtual-list/tree/17.x) | [17.0.22](https://www.npmjs.com/package/ng-virtual-list/v/17.0.22) |
|
|
485
|
+
| 16.x | 16.0.24 | [16.x](https://github.com/DjonnyX/ng-virtual-list/tree/16.x) | [16.0.24](https://www.npmjs.com/package/ng-virtual-list/v/16.0.24) |
|
|
486
|
+
| 15.x | 15.0.23 | [15.x](https://github.com/DjonnyX/ng-virtual-list/tree/15.x) | [15.0.23](https://www.npmjs.com/package/ng-virtual-list/v/15.0.23) |
|
|
487
|
+
| 14.x | 14.0.24 | [14.x](https://github.com/DjonnyX/ng-virtual-list/tree/14.x) | [14.0.24](https://www.npmjs.com/package/ng-virtual-list/v/14.0.24) |
|
|
488
488
|
|
|
489
489
|
<br/>
|
|
490
490
|
|
package/ng-package.json
ADDED
package/package.json
CHANGED
|
@@ -1,41 +1,30 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "ng-virtual-list",
|
|
3
|
-
"version": "20.0.
|
|
4
|
-
"author": {
|
|
5
|
-
"name": "Evgenii Grebennikov",
|
|
6
|
-
"email": "djonnyx@gmail.com"
|
|
7
|
-
},
|
|
8
|
-
"license": "MIT",
|
|
9
|
-
"homepage": "https://github.com/djonnyx/ng-virtual-list/tree/main/projects/ng-virtual-list",
|
|
10
|
-
"keywords": [
|
|
11
|
-
"ng",
|
|
12
|
-
"angular",
|
|
13
|
-
"virtual",
|
|
14
|
-
"virtualized",
|
|
15
|
-
"list",
|
|
16
|
-
"group",
|
|
17
|
-
"grouped",
|
|
18
|
-
"scroll",
|
|
19
|
-
"scrolling",
|
|
20
|
-
"scroller"
|
|
21
|
-
],
|
|
22
|
-
"peerDependencies": {
|
|
23
|
-
"@angular/common": "^20.0.4",
|
|
24
|
-
"@angular/core": "^20.0.4"
|
|
25
|
-
},
|
|
26
|
-
"dependencies": {
|
|
27
|
-
"tslib": "^2.3.0"
|
|
28
|
-
},
|
|
29
|
-
"sideEffects": false
|
|
30
|
-
"module": "fesm2022/ng-virtual-list.mjs",
|
|
31
|
-
"typings": "index.d.ts",
|
|
32
|
-
"exports": {
|
|
33
|
-
"./package.json": {
|
|
34
|
-
"default": "./package.json"
|
|
35
|
-
},
|
|
36
|
-
".": {
|
|
37
|
-
"types": "./index.d.ts",
|
|
38
|
-
"default": "./fesm2022/ng-virtual-list.mjs"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "ng-virtual-list",
|
|
3
|
+
"version": "20.0.32",
|
|
4
|
+
"author": {
|
|
5
|
+
"name": "Evgenii Grebennikov",
|
|
6
|
+
"email": "djonnyx@gmail.com"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"homepage": "https://github.com/djonnyx/ng-virtual-list/tree/main/projects/ng-virtual-list",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"ng",
|
|
12
|
+
"angular",
|
|
13
|
+
"virtual",
|
|
14
|
+
"virtualized",
|
|
15
|
+
"list",
|
|
16
|
+
"group",
|
|
17
|
+
"grouped",
|
|
18
|
+
"scroll",
|
|
19
|
+
"scrolling",
|
|
20
|
+
"scroller"
|
|
21
|
+
],
|
|
22
|
+
"peerDependencies": {
|
|
23
|
+
"@angular/common": "^20.0.4",
|
|
24
|
+
"@angular/core": "^20.0.4"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"tslib": "^2.3.0"
|
|
28
|
+
},
|
|
29
|
+
"sideEffects": false
|
|
41
30
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
@let item = data();
|
|
2
|
+
@let renderer = itemRenderer();
|
|
3
|
+
|
|
4
|
+
@if (item) {
|
|
5
|
+
<li #listItem part="item" class="ngvl-item__container" [ngClass]="{'snapped': item.config.snapped,
|
|
6
|
+
'snapped-out': item.config.snappedOut}">
|
|
7
|
+
@if (renderer) {
|
|
8
|
+
<ng-container [ngTemplateOutlet]="renderer"
|
|
9
|
+
[ngTemplateOutletContext]="{data: item.data || {}, config: item.config}" />
|
|
10
|
+
}
|
|
11
|
+
</li>
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
position: absolute;
|
|
4
|
+
left: 0;
|
|
5
|
+
top: 0;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
overflow: hidden;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.ngvl-item__container {
|
|
11
|
+
margin: 0;
|
|
12
|
+
padding: 0;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
background-color: #ffffff;
|
|
15
|
+
width: inherit;
|
|
16
|
+
height: inherit;
|
|
17
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { NgVirtualListItemComponent } from './ng-virtual-list-item.component';
|
|
4
|
+
|
|
5
|
+
describe('NgVirtualListItemComponent', () => {
|
|
6
|
+
let component: NgVirtualListItemComponent;
|
|
7
|
+
let fixture: ComponentFixture<NgVirtualListItemComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [NgVirtualListItemComponent]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
|
|
15
|
+
fixture = TestBed.createComponent(NgVirtualListItemComponent);
|
|
16
|
+
component = fixture.componentInstance;
|
|
17
|
+
fixture.detectChanges();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should create', () => {
|
|
21
|
+
expect(component).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { ChangeDetectionStrategy, Component, ElementRef, inject, signal, TemplateRef } from '@angular/core';
|
|
3
|
+
import { IRenderVirtualListItem } from '../models/render-item.model';
|
|
4
|
+
import { ISize } from '../types';
|
|
5
|
+
import {
|
|
6
|
+
POSITION_ABSOLUTE, POSITION_STICKY, PX, SIZE_100_PERSENT, SIZE_AUTO, TRANSLATE_3D, VISIBILITY_HIDDEN,
|
|
7
|
+
VISIBILITY_VISIBLE, ZEROS_TRANSLATE_3D,
|
|
8
|
+
} from '../const';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Virtual list item component
|
|
12
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/components/ng-virtual-list-item.component.ts
|
|
13
|
+
* @author Evgenii Grebennikov
|
|
14
|
+
* @email djonnyx@gmail.com
|
|
15
|
+
*/
|
|
16
|
+
@Component({
|
|
17
|
+
selector: 'ng-virtual-list-item',
|
|
18
|
+
imports: [CommonModule],
|
|
19
|
+
templateUrl: './ng-virtual-list-item.component.html',
|
|
20
|
+
styleUrl: './ng-virtual-list-item.component.scss',
|
|
21
|
+
host: {
|
|
22
|
+
'class': 'ngvl__item',
|
|
23
|
+
},
|
|
24
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
25
|
+
})
|
|
26
|
+
export class NgVirtualListItemComponent {
|
|
27
|
+
private static __nextId: number = 0;
|
|
28
|
+
|
|
29
|
+
private _id!: number;
|
|
30
|
+
get id() {
|
|
31
|
+
return this._id;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
data = signal<IRenderVirtualListItem | undefined>(undefined);
|
|
35
|
+
private _data: IRenderVirtualListItem | undefined = undefined;
|
|
36
|
+
set item(v: IRenderVirtualListItem | undefined) {
|
|
37
|
+
if (this._data === v) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const data = this._data = v;
|
|
42
|
+
|
|
43
|
+
if (data) {
|
|
44
|
+
const styles = this._elementRef.nativeElement.style;
|
|
45
|
+
styles.zIndex = String(data.config.sticky);
|
|
46
|
+
if (data.config.snapped) {
|
|
47
|
+
styles.transform = ZEROS_TRANSLATE_3D;
|
|
48
|
+
styles.position = POSITION_STICKY;
|
|
49
|
+
} else {
|
|
50
|
+
styles.position = POSITION_ABSOLUTE;
|
|
51
|
+
styles.transform = `${TRANSLATE_3D}(${data.config.isVertical ? 0 : data.measures.x}${PX}, ${data.config.isVertical ? data.measures.y : 0}${PX} , 0)`;
|
|
52
|
+
}
|
|
53
|
+
styles.height = data.config.isVertical ? data.config.dynamic ? SIZE_AUTO : `${data.measures.height}${PX}` : SIZE_100_PERSENT;
|
|
54
|
+
styles.width = data.config.isVertical ? SIZE_100_PERSENT : data.config.dynamic ? SIZE_AUTO : `${data.measures.width}${PX}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
this.data.set(v);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
get item() {
|
|
61
|
+
return this._data;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
get itemId() {
|
|
65
|
+
return this._data?.id;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
itemRenderer = signal<TemplateRef<any> | undefined>(undefined);
|
|
69
|
+
|
|
70
|
+
set renderer(v: TemplateRef<any> | undefined) {
|
|
71
|
+
this.itemRenderer.set(v);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private _elementRef: ElementRef<HTMLElement> = inject(ElementRef<HTMLElement>);
|
|
75
|
+
get element() {
|
|
76
|
+
return this._elementRef.nativeElement;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
constructor() {
|
|
80
|
+
this._id = NgVirtualListItemComponent.__nextId = NgVirtualListItemComponent.__nextId === Number.MAX_SAFE_INTEGER
|
|
81
|
+
? 0 : NgVirtualListItemComponent.__nextId + 1;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
getBounds(): ISize {
|
|
85
|
+
const el: HTMLElement = this._elementRef.nativeElement,
|
|
86
|
+
{ width, height } = el.getBoundingClientRect();
|
|
87
|
+
return { width, height };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
show() {
|
|
91
|
+
const styles = this._elementRef.nativeElement.style;
|
|
92
|
+
if (styles.visibility === VISIBILITY_VISIBLE) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
styles.visibility = VISIBILITY_VISIBLE;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
hide() {
|
|
100
|
+
const styles = this._elementRef.nativeElement.style;
|
|
101
|
+
if (styles.visibility === VISIBILITY_HIDDEN) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
styles.visibility = VISIBILITY_HIDDEN;
|
|
106
|
+
styles.transform = ZEROS_TRANSLATE_3D;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Directions } from "../enums/directions";
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_ITEM_SIZE = 24;
|
|
4
|
+
|
|
5
|
+
export const DEFAULT_ITEMS_OFFSET = 2;
|
|
6
|
+
|
|
7
|
+
export const DEFAULT_LIST_SIZE = 400;
|
|
8
|
+
|
|
9
|
+
export const DEFAULT_SNAP = false;
|
|
10
|
+
|
|
11
|
+
export const DEFAULT_ENABLED_BUFFER_OPTIMIZATION = false;
|
|
12
|
+
|
|
13
|
+
export const DEFAULT_DYNAMIC_SIZE = false;
|
|
14
|
+
|
|
15
|
+
export const TRACK_BY_PROPERTY_NAME = 'id';
|
|
16
|
+
|
|
17
|
+
export const DEFAULT_DIRECTION = Directions.VERTICAL;
|
|
18
|
+
|
|
19
|
+
export const DISPLAY_OBJECTS_LENGTH_MESUREMENT_ERROR = 1;
|
|
20
|
+
|
|
21
|
+
export const MAX_SCROLL_TO_ITERATIONS = 5;
|
|
22
|
+
|
|
23
|
+
// presets
|
|
24
|
+
|
|
25
|
+
export const BEHAVIOR_AUTO = 'auto';
|
|
26
|
+
|
|
27
|
+
export const BEHAVIOR_INSTANT = 'instant';
|
|
28
|
+
|
|
29
|
+
export const BEHAVIOR_SMOOTH = 'smooth';
|
|
30
|
+
|
|
31
|
+
export const VISIBILITY_VISIBLE = 'visible';
|
|
32
|
+
|
|
33
|
+
export const VISIBILITY_HIDDEN = 'hidden';
|
|
34
|
+
|
|
35
|
+
export const SIZE_100_PERSENT = '100%';
|
|
36
|
+
|
|
37
|
+
export const SIZE_AUTO = 'auto';
|
|
38
|
+
|
|
39
|
+
export const POSITION_ABSOLUTE = 'absolute';
|
|
40
|
+
|
|
41
|
+
export const POSITION_STICKY = 'sticky';
|
|
42
|
+
|
|
43
|
+
export const TRANSLATE_3D = 'translate3d';
|
|
44
|
+
|
|
45
|
+
export const ZEROS_TRANSLATE_3D = `${TRANSLATE_3D}(0,0,0)`;
|
|
46
|
+
|
|
47
|
+
export const TOP_PROP_NAME = 'top';
|
|
48
|
+
|
|
49
|
+
export const LEFT_PROP_NAME = 'left';
|
|
50
|
+
|
|
51
|
+
export const X_PROP_NAME = 'x';
|
|
52
|
+
|
|
53
|
+
export const Y_PROP_NAME = 'y';
|
|
54
|
+
|
|
55
|
+
export const WIDTH_PROP_NAME = 'width';
|
|
56
|
+
|
|
57
|
+
export const HEIGHT_PROP_NAME = 'height';
|
|
58
|
+
|
|
59
|
+
export const PX = 'px';
|
|
60
|
+
|
|
61
|
+
export const SCROLL = 'scroll';
|
|
62
|
+
|
|
63
|
+
export const SCROLL_END = 'scrollend';
|
|
64
|
+
|
|
65
|
+
export const CLASS_LIST_VERTICAL = 'vertical';
|
|
66
|
+
|
|
67
|
+
export const CLASS_LIST_HORIZONTAL = 'horizontal';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Directions } from "./directions";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Axis of the arrangement of virtual list elements.
|
|
5
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/enums/direction.ts
|
|
6
|
+
* @author Evgenii Grebennikov
|
|
7
|
+
* @email djonnyx@gmail.com
|
|
8
|
+
*/
|
|
9
|
+
export type Direction = Directions | 'hotizontal' | 'vertical';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Axis of the arrangement of virtual list elements.
|
|
3
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/enums/directions.ts
|
|
4
|
+
* @author Evgenii Grebennikov
|
|
5
|
+
* @email djonnyx@gmail.com
|
|
6
|
+
*/
|
|
7
|
+
export enum Directions {
|
|
8
|
+
/**
|
|
9
|
+
* Horizontal axis.
|
|
10
|
+
*/
|
|
11
|
+
HORIZONTAL = 'horizontal',
|
|
12
|
+
/**
|
|
13
|
+
* Vertical axis.
|
|
14
|
+
*/
|
|
15
|
+
VERTICAL = 'vertical',
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IVirtualListItem } from "./item.model";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Virtual list elements collection interface
|
|
5
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/collection.model.ts
|
|
6
|
+
* @author Evgenii Grebennikov
|
|
7
|
+
* @email djonnyx@gmail.com
|
|
8
|
+
*/
|
|
9
|
+
export interface IVirtualListCollection extends Array<IVirtualListItem> { };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ScrollDirection } from './scroll-direction.model';
|
|
2
|
+
import { IScrollEvent } from './scroll-event.model';
|
|
3
|
+
import { IVirtualListItem } from './item.model';
|
|
4
|
+
import { IVirtualListStickyMap } from './sticky-map.model';
|
|
5
|
+
import { IVirtualListCollection } from './collection.model';
|
|
6
|
+
|
|
7
|
+
export type {
|
|
8
|
+
ScrollDirection,
|
|
9
|
+
IScrollEvent,
|
|
10
|
+
IVirtualListItem,
|
|
11
|
+
IVirtualListStickyMap,
|
|
12
|
+
IVirtualListCollection,
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Id } from "../types/id";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Virtual list element model
|
|
5
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/item.model.ts
|
|
6
|
+
* @author Evgenii Grebennikov
|
|
7
|
+
* @email djonnyx@gmail.com
|
|
8
|
+
*/
|
|
9
|
+
export interface IVirtualListItem {
|
|
10
|
+
/**
|
|
11
|
+
* Unique identifier of the element.
|
|
12
|
+
*/
|
|
13
|
+
id: Id;
|
|
14
|
+
[x: string]: any;
|
|
15
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IRenderVirtualListItem } from "./render-item.model";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Virtual list screen elements collection interface
|
|
5
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/render-collection.model.ts
|
|
6
|
+
* @author Evgenii Grebennikov
|
|
7
|
+
* @email djonnyx@gmail.com
|
|
8
|
+
*/
|
|
9
|
+
export interface IRenderVirtualListCollection extends Array<IRenderVirtualListItem> { };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Object with configuration parameters for IRenderVirtualListItem
|
|
3
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/render-item-config.model.ts
|
|
4
|
+
* @author Evgenii Grebennikov
|
|
5
|
+
* @email djonnyx@gmail.com
|
|
6
|
+
*
|
|
7
|
+
*/
|
|
8
|
+
export interface IRenderVirtualListItemConfig {
|
|
9
|
+
/**
|
|
10
|
+
* If greater than 0, the element will have a sticky position with the given zIndex.
|
|
11
|
+
*/
|
|
12
|
+
sticky: number;
|
|
13
|
+
/**
|
|
14
|
+
* Specifies whether the element will snap.
|
|
15
|
+
*/
|
|
16
|
+
snap: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Indicates that the element is snapped.
|
|
19
|
+
*/
|
|
20
|
+
snapped: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Indicates that the element is being shifted by another snap element.
|
|
23
|
+
*/
|
|
24
|
+
snappedOut: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Indicates that the element is a vertical list item.
|
|
27
|
+
*/
|
|
28
|
+
isVertical: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Specifies that the element adapts to the size of its content.
|
|
31
|
+
*/
|
|
32
|
+
dynamic: boolean;
|
|
33
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IRect } from "../types";
|
|
2
|
+
import { Id } from "../types/id";
|
|
3
|
+
import { IVirtualListItem } from "./item.model";
|
|
4
|
+
import { IRenderVirtualListItemConfig } from "./render-item-config.model";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* List screen element model
|
|
8
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/render-item.model.ts
|
|
9
|
+
* @author Evgenii Grebennikov
|
|
10
|
+
* @email djonnyx@gmail.com
|
|
11
|
+
*/
|
|
12
|
+
export interface IRenderVirtualListItem {
|
|
13
|
+
/**
|
|
14
|
+
* Unique identifier of the element.
|
|
15
|
+
*/
|
|
16
|
+
id: Id;
|
|
17
|
+
/**
|
|
18
|
+
* Element metrics.
|
|
19
|
+
*/
|
|
20
|
+
measures: IRect;
|
|
21
|
+
/**
|
|
22
|
+
* Element data.
|
|
23
|
+
*/
|
|
24
|
+
data: IVirtualListItem;
|
|
25
|
+
/**
|
|
26
|
+
* Object with configuration parameters for IRenderVirtualListItem.
|
|
27
|
+
*/
|
|
28
|
+
config: IRenderVirtualListItemConfig;
|
|
29
|
+
};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { ScrollDirection } from "./scroll-direction.model";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Interface IScrollEvent.
|
|
5
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/scroll-event.model.ts
|
|
6
|
+
* @author Evgenii Grebennikov
|
|
7
|
+
* @email djonnyx@gmail.com
|
|
8
|
+
*/
|
|
9
|
+
export interface IScrollEvent {
|
|
10
|
+
/**
|
|
11
|
+
* Scroll area offset
|
|
12
|
+
*/
|
|
13
|
+
scrollSize: number;
|
|
14
|
+
/**
|
|
15
|
+
* Full size of the scroll area
|
|
16
|
+
*/
|
|
17
|
+
scrollWeight: number;
|
|
18
|
+
/**
|
|
19
|
+
* Viewport size
|
|
20
|
+
*/
|
|
21
|
+
size: number;
|
|
22
|
+
/**
|
|
23
|
+
* Size of the list of elements
|
|
24
|
+
*/
|
|
25
|
+
listSize: number;
|
|
26
|
+
/**
|
|
27
|
+
* Specifies whether the list orientation is vertical.
|
|
28
|
+
*/
|
|
29
|
+
isVertical: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* A value of -1 indicates the direction is up or left (if the list direction is horizontal).
|
|
32
|
+
* A value of 1 indicates the direction is down or right (if the list direction is horizontal).
|
|
33
|
+
*/
|
|
34
|
+
direction: ScrollDirection;
|
|
35
|
+
/**
|
|
36
|
+
* If true then indicates that the list has been scrolled to the end.
|
|
37
|
+
*/
|
|
38
|
+
isStart: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* If true then indicates that the list has been scrolled to the end.
|
|
41
|
+
*/
|
|
42
|
+
isEnd: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Delta of marked and unmarked area
|
|
45
|
+
*/
|
|
46
|
+
delta: number;
|
|
47
|
+
/**
|
|
48
|
+
* Scroll delta
|
|
49
|
+
*/
|
|
50
|
+
scrollDelta: number;
|
|
51
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
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.
|
|
3
|
+
* @link https://github.com/DjonnyX/ng-virtual-list/blob/20.x/projects/ng-virtual-list/src/lib/models/sticky-map.model.ts
|
|
4
|
+
* @author Evgenii Grebennikov
|
|
5
|
+
* @email djonnyx@gmail.com
|
|
6
|
+
*/
|
|
7
|
+
export interface IVirtualListStickyMap {
|
|
8
|
+
/**
|
|
9
|
+
* Sets zIndex for the element ID. If zIndex is greater than 0, then sticky position is applied.
|
|
10
|
+
*/
|
|
11
|
+
[id: string]: number;
|
|
12
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
width: 400px; // default
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
:host(.horizontal) {
|
|
8
|
+
height: 48px; // default
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
:host(.vertical) {
|
|
12
|
+
height: 320px; // default
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.ngvl__container {
|
|
16
|
+
overflow: auto;
|
|
17
|
+
width: 100%;
|
|
18
|
+
height: 100%;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.ngvl__list {
|
|
22
|
+
position: relative;
|
|
23
|
+
list-style: none;
|
|
24
|
+
padding: 0;
|
|
25
|
+
margin: 0;
|
|
26
|
+
width: 100%;
|
|
27
|
+
height: 100%;
|
|
28
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { NgVirtualListComponent } from './ng-virtual-list.component';
|
|
4
|
+
|
|
5
|
+
describe('NgVirtualListComponent', () => {
|
|
6
|
+
let component: NgVirtualListComponent;
|
|
7
|
+
let fixture: ComponentFixture<NgVirtualListComponent>;
|
|
8
|
+
|
|
9
|
+
beforeEach(async () => {
|
|
10
|
+
await TestBed.configureTestingModule({
|
|
11
|
+
imports: [NgVirtualListComponent]
|
|
12
|
+
})
|
|
13
|
+
.compileComponents();
|
|
14
|
+
|
|
15
|
+
fixture = TestBed.createComponent(NgVirtualListComponent);
|
|
16
|
+
component = fixture.componentInstance;
|
|
17
|
+
fixture.detectChanges();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should create', () => {
|
|
21
|
+
expect(component).toBeTruthy();
|
|
22
|
+
});
|
|
23
|
+
});
|