ng-virtual-list 21.11.2 → 21.12.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.
- package/README.md +75 -48
- package/fesm2022/ng-virtual-list.mjs +5416 -3100
- package/fesm2022/ng-virtual-list.mjs.map +1 -1
- package/package.json +3 -2
- package/types/ng-virtual-list.d.ts +1413 -531
package/README.md
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
# NgVirtualList
|
|
2
2
|
|
|
3
|
-
🚀 High-performance virtual scrolling for Angular apps. Render
|
|
3
|
+
🚀 High-performance virtual scrolling for Angular apps. Render 10,000+ items in Angular without breaking a sweat. Smooth, customizable, and developer-friendly.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
⚡A powerful API for implementing lists of varying functionality and complexity.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
✨Flexible, and actively maintained Angular library that excels with high-performance, feature-rich virtualized lists—including grouping, sticky headers, snapping, animations, collapsing group elements, single and multiple selection of elements and both scroll directions, lists with scrolling bindings for elements, galleries of varying complexity, including 3D transformations of elements and effects such as MotionBlur, DOF (Depth Of Field) and Fog. Whether you're rendering millions of items or building interactive list components, it delivers scalability and customization. Angular (14–22) compatibility.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
🧬The main advantage of this solution is the elimination of the "empty spaces" effect during fast scrolling, which occurs in the classic implementation of virtualized lists. Visualization is as close as possible to native lists.
|
|
10
|
+
|
|
11
|
+
💻 Works correctly in all browsers and platforms.
|
|
12
|
+
|
|
13
|
+
💪 The software portion of the project was completed without a single line of code written using AI (artificial intelligence)!
|
|
10
14
|
|
|
11
15
|
<img width="1033" height="171" alt="logo" src="https://github.com/user-attachments/assets/b559cfde-405a-4361-b71b-6715478d997d" />
|
|
12
16
|
|
|
@@ -16,16 +20,7 @@ Works correctly in all browsers and platforms.
|
|
|
16
20
|

|
|
17
21
|

|
|
18
22
|
|
|
19
|
-
[
|
|
20
|
-
[(Code)](https://github.com/DjonnyX/ng-virtual-list-chat-demo)
|
|
21
|
-
|
|
22
|
-
[News Feed Demo](https://news-feed-demo.eugene-grebennikov.pro/)
|
|
23
|
-
[(Code)](https://github.com/DjonnyX/ng-virtual-list-news-feed-demo)
|
|
24
|
-
|
|
25
|
-
[Live Examples (Storybook)](https://ng-virtual-list-examples.eugene-grebennikov.pro/)
|
|
26
|
-
|
|
27
|
-
[Examples](https://ng-virtual-list.eugene-grebennikov.pro/)
|
|
28
|
-
[(Code)](https://github.com/DjonnyX/ng-virtual-list-demo/tree/main/src/app)
|
|
23
|
+
[Documentation](https://ng-virtual-list.eugene-grebennikov.pro/)
|
|
29
24
|
|
|
30
25
|
<br/>
|
|
31
26
|
|
|
@@ -127,12 +122,12 @@ items = Array.from({ length: 100000 }, (_, i) => ({ id: i, name: `Item #${i}` })
|
|
|
127
122
|
Template:
|
|
128
123
|
```html
|
|
129
124
|
<ng-virtual-list class="list" direction="horizontal" [items]="horizontalItems" [bufferSize]="1" [maxBufferSize]="5"
|
|
130
|
-
[itemRenderer]="horizontalItemRenderer" [dynamicSize]="false" [itemSize]="64" [
|
|
125
|
+
[itemRenderer]="horizontalItemRenderer" [dynamicSize]="false" [itemSize]="64" [selectingMode]="'select'"
|
|
131
126
|
[selectedIds]="2" (onSelect)="onSelect($event)" (onItemClick)="onItemClick($event)"></ng-virtual-list>
|
|
132
127
|
|
|
133
128
|
<ng-template #horizontalItemRenderer let-data="data" let-config="config">
|
|
134
129
|
@if (data) {
|
|
135
|
-
<div [ngClass]="{'list__h-container': true, 'selected':
|
|
130
|
+
<div [ngClass]="{'list__h-container': true, 'selected': api.selected}">
|
|
136
131
|
<span>{{data.name}}</span>
|
|
137
132
|
</div>
|
|
138
133
|
}
|
|
@@ -177,8 +172,7 @@ export class AppComponent {
|
|
|
177
172
|
Template:
|
|
178
173
|
```html
|
|
179
174
|
<ng-virtual-list class="list" direction="horizontal" [items]="horizontalGroupItems" [itemRenderer]="horizontalGroupItemRenderer"
|
|
180
|
-
[bufferSize]="1" [maxBufferSize]="5" [itemConfigMap]="horizontalGroupItemConfigMap" [dynamicSize]="false" [itemSize]="54" [
|
|
181
|
-
methodForSelecting="multi-select" [selectedIds]="[3,2]" (onSelect)="onSelect($event)" (onItemClick)="onItemClick($event)"></ng-virtual-list>
|
|
175
|
+
[bufferSize]="1" [maxBufferSize]="5" [itemConfigMap]="horizontalGroupItemConfigMap" [dynamicSize]="false" [itemSize]="54" [stickyEnabled]="true" selectingMode="multi-select" [selectedIds]="[3,2]" (onSelect)="onSelect($event)" (onItemClick)="onItemClick($event)"></ng-virtual-list>
|
|
182
176
|
|
|
183
177
|
<ng-template #horizontalGroupItemRenderer let-data="data" let-config="config">
|
|
184
178
|
@if (data) {
|
|
@@ -189,7 +183,7 @@ Template:
|
|
|
189
183
|
</div>
|
|
190
184
|
}
|
|
191
185
|
@default {
|
|
192
|
-
<div [ngClass]="{'list__h-container': true, 'selected':
|
|
186
|
+
<div [ngClass]="{'list__h-container': true, 'selected': api.selected}">
|
|
193
187
|
<span>{{data.name}}</span>
|
|
194
188
|
</div>
|
|
195
189
|
}
|
|
@@ -292,7 +286,7 @@ export class AppComponent {
|
|
|
292
286
|
Template:
|
|
293
287
|
```html
|
|
294
288
|
<ng-virtual-list class="list simple" [items]="groupItems" [bufferSize]="1" [maxBufferSize]="5" [itemRenderer]="groupItemRenderer"
|
|
295
|
-
[itemConfigMap]="groupItemConfigMap" [dynamicSize]="false" [itemSize]="40" [
|
|
289
|
+
[itemConfigMap]="groupItemConfigMap" [dynamicSize]="false" [itemSize]="40" [stickyEnabled]="false"></ng-virtual-list>
|
|
296
290
|
|
|
297
291
|
<ng-template #groupItemRenderer let-data="data">
|
|
298
292
|
@if (data) {
|
|
@@ -319,7 +313,7 @@ Template:
|
|
|
319
313
|
Template (with snapping):
|
|
320
314
|
```html
|
|
321
315
|
<ng-virtual-list class="list simple" [items]="groupItems" [bufferSize]="1" [maxBufferSize]="5" [itemRenderer]="groupItemRenderer"
|
|
322
|
-
[itemConfigMap]="groupItemConfigMap" [dynamicSize]="false" [itemSize]="40" [
|
|
316
|
+
[itemConfigMap]="groupItemConfigMap" [dynamicSize]="false" [itemSize]="40" [stickyEnabled]="true"></ng-virtual-list>
|
|
323
317
|
|
|
324
318
|
<ng-template #groupItemRenderer let-data="data">
|
|
325
319
|
@if (data) {
|
|
@@ -438,7 +432,7 @@ Virtual list with height-adjustable elements.
|
|
|
438
432
|
Template
|
|
439
433
|
```html
|
|
440
434
|
<ng-virtual-list #dynamicList class="list" [items]="groupDynamicItems" [itemRenderer]="groupItemRenderer" [bufferSize]="1" [maxBufferSize]="5"
|
|
441
|
-
[itemConfigMap]="groupDynamicItemConfigMap" [
|
|
435
|
+
[itemConfigMap]="groupDynamicItemConfigMap" [stickyEnabled]="true"></ng-virtual-list>
|
|
442
436
|
|
|
443
437
|
<ng-template #groupItemRenderer let-data="data">
|
|
444
438
|
@if (data) {
|
|
@@ -601,35 +595,52 @@ Inputs
|
|
|
601
595
|
|
|
602
596
|
| Property | Type | Description |
|
|
603
597
|
|---|---|---|
|
|
604
|
-
|
|
|
598
|
+
| alignment | [Alignment](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/alignment.ts) | Determines the alignment of the list. Two modes are available: `none` and `center`. The `center` mode aligns the list items to the center of the viewport, ideal for use with the `itemTransform` property. The `none` mode means no alignment. The default value is `none`. |
|
|
599
|
+
| animationParams | [IAnimationParams](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/interfaces/animation-params.ts)? = { scrollToItem: 50, snapToItem: 150, navigateToItem: 150, navigateByKeyboard: 50 } | Animation parameters. The default value is "{ scrollToItem: 50, snapToItem: 150, navigateToItem: 150, navigateByKeyboard: 50 }". |
|
|
605
600
|
| bufferSize | number? = 2 | Number of elements outside the scope of visibility. Default value is 2. |
|
|
606
|
-
|
|
|
601
|
+
| clickDistance | number? = 40 | The maximum scroll distance at which a click event is triggered. |
|
|
607
602
|
| collapsedIds | Array<[Id](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/types/id.ts)> | Sets the collapsed items. |
|
|
608
603
|
| collapseByClick | boolean? = true | If `false`, the element is collapsed using the config.collapse method passed to the template; if `true`, the element is collapsed by clicking on it. The default value is `true`. |
|
|
604
|
+
| collapsingMode | [CollapsingMode](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/collapsing-modes.ts) | Mode for collapsing list items. Default value is `none`. `none` - List items are not selectable. `multi-collapse` - List items are collapsed one by one. 'accordion' - Accordion collapsible list items. Default value is `multi-collapse`. |
|
|
609
605
|
| collectionMode | [CollectionMode? = 'normal'](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/collection-mode.ts) | Determines the action modes for collection elements. Default value is `normal`. |
|
|
606
|
+
| divides | number = 1 | Column or row numbers. The default value is `1`. |
|
|
610
607
|
| direction | [Direction? = 'vertical'](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/direction.ts) | Determines the direction in which elements are placed. Default value is "vertical". |
|
|
611
608
|
| dynamicSize | boolean? = true | If true, items in the list may have different sizes, and the itemSize property must be specified to adjust the sizes of items in the unallocated area. If false then the items in the list have a fixed size specified by the itemSize property. The default value is true. |
|
|
612
|
-
| enabledBufferOptimization | boolean? =
|
|
609
|
+
| enabledBufferOptimization | boolean? = false | Experimental! Enables buffer optimization. Can only be used if items in the collection are not added or updated. |
|
|
613
610
|
| id | number | Readonly. Returns the unique identifier of the component. |
|
|
614
611
|
| items | [IVirtualListCollection](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/models/collection.model.ts) | Collection of list items. The collection of elements must be immutable. |
|
|
615
|
-
| itemSize | number
|
|
612
|
+
| itemSize | number \| 'viewport' = 24 | If direction = 'vertical', then the height of a typical element. If direction = 'horizontal', then the width of a typical element. If the dynamicSize property is true, the items in the list can have different sizes, and you must specify the itemSize property to adjust the sizes of the items in the unallocated area. If the value is 'viewport', the sizes of elements are automatically resized to fit the viewport size. |
|
|
613
|
+
| itemTransform | [ItemTransform](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/types/item-transform.ts) \| null = null | Custom transformation of element's position, rotation, scale, opacity and zIndex. The default value is `null`. |
|
|
616
614
|
| itemRenderer | TemplateRef | Rendering element template. |
|
|
617
|
-
| itemConfigMap | [IVirtualListItemConfigMap?](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/models/item-config-map.model.ts) | Sets `sticky` position and `selectable` for the list item element. If `sticky` position is greater than `0`, then `sticky` position is applied.
|
|
618
|
-
|
|
615
|
+
| itemConfigMap | [IVirtualListItemConfigMap?](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/models/item-config-map.model.ts) | Sets `sticky` position, `fullSize`, `collapsable` and `selectable` for the list item element. If `sticky` position is greater than `0`, then `sticky` position is applied.
|
|
616
|
+
If the `sticky` value is greater than `0`, then the `sticky` position mode is enabled for the element. `1` - position start, `2` - position end. Default value is `0`.
|
|
617
|
+
`selectable` determines whether an element can be selected or not. Default value is `true`.
|
|
618
|
+
`collapsable` determines whether an element with a `sticky` property greater than zero can collapse and collapse elements in front that do not have a `sticky` property.
|
|
619
|
+
`fullSize` determines the size of an element when rendering lists with cell divisions. If sticky is 1 or 2, fullSize automatically becomes true. The default value is false. |
|
|
619
620
|
| langTextDir | [TextDirection? = 'ltr'](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/text-direction.ts) | A string indicating the direction of text for the locale. Can be either "ltr" (left-to-right) or "rtl" (right-to-left). |
|
|
620
621
|
| loading | boolean? = false | If `true`, the scrollBar goes into loading state. The default value is `false`. |
|
|
622
|
+
| maxBufferSize | number? = 10 | Maximum number of elements outside the scope of visibility. Default value is 10. If maxBufferSize is set to be greater than bufferSize, then adaptive buffer mode is enabled. The greater the scroll size, the more elements are allocated for rendering. |
|
|
623
|
+
| maxMotionBlur | number = 0.5 | Maximum motion blur effect. The default value is `0.5`. |
|
|
624
|
+
| selectingMode | [SelectingMode](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/selecting-mode.ts) | Method for selecting list items. Default value is 'none'. 'select' - List items are selected one by one. 'multi-select' - Multiple selection of list items. 'none' - List items are not selectable. |
|
|
625
|
+
| minItemSize | number \| 'viewport' = 1 | If the `dynamicSize` property is enabled, the minimum size of the element is set. If the value is 'viewport', the sizes of elements are automatically resized to fit the viewport size. |
|
|
626
|
+
| maxItemSize | number \| 'viewport' = Number.MAX_SAFE_INTEGER | If the `dynamicSize` property is enabled, the maximum size of the element is set. If the value is 'viewport', the sizes of elements are automatically resized to fit the viewport size. |
|
|
627
|
+
| motionBlur | number \| 'disabled' = 0.15 | Motion blur effect. The default value is `0.25`. |
|
|
628
|
+
| motionBlurEnabled | boolean = false | Determines whether to apply motion blur or not. The default value is `false`. |
|
|
621
629
|
| overscrollEnabled | boolean? = true | Determines whether the overscroll (re-scroll) feature will work. The default value is "true". |
|
|
630
|
+
| overlappingScrollbar | boolean? = false | Determines whether the scroll bar will overlap the list. The default value is "false". |
|
|
622
631
|
| selectByClick | boolean? = true | If `false`, the element is selected using the config.select method passed to the template; if `true`, the element is selected by clicking on it. The default value is `true`. |
|
|
623
|
-
|
|
|
632
|
+
| stickyEnabled | boolean? = false | Determines whether items with the given `sticky` in `itemConfigMap` will stick to the edges. Default value is "false". |
|
|
624
633
|
| selectedIds | Array<[Id](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/types/id.ts)> \| [Id](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/types/id.ts) \| null | Sets the selected items. |
|
|
625
634
|
| screenReaderMessage | string? = "Showing items $1 to $2" | Message for screen reader. The message format is: "some text `$1` some text `$2`", where `$1` is the number of the first element of the screen collection, `$2` is the number of the last element of the screen collection. |
|
|
626
|
-
| clickDistance | number? = 40 | The maximum scroll distance at which a click event is triggered. |
|
|
627
635
|
| waitForPreparation | boolean? = true | If true, it will wait until the list items are fully prepared before displaying them.. The default value is `true`. |
|
|
628
|
-
| scrollStartOffset |
|
|
629
|
-
| scrollEndOffset |
|
|
630
|
-
|
|
|
631
|
-
|
|
|
632
|
-
|
|
|
636
|
+
| scrollStartOffset | [FloatOrPersentageValue](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/types/float-or-persentage-value.ts) = 0 | Sets the scroll start offset value. Can be specified in absolute or percentage values. Supports arithmetic expressions of addition `50% + 25` or subtraction `50% - 25`. Default value is "0". |
|
|
637
|
+
| scrollEndOffset | [FloatOrPersentageValue](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/types/float-or-persentage-value.ts) = 0 | Sets the scroll end offset value. Can be specified in absolute or percentage values. Supports arithmetic expressions of addition `50% + 25` or subtraction `50% - 25`. Default value is "0". |
|
|
638
|
+
| snapToItem | boolean = false | Snap to an item. The default value is `false`. |
|
|
639
|
+
| snapToItemAlign | [SnapToItemAlign](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/snap-to-item-align.ts) = [SnapToItemAligns](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/snap-to-item-aligns.ts).CENTER | Alignment for snapToItem. Available values are `start`, `center`, and `end`. The default value is `center`. |
|
|
640
|
+
| snappingDistance | [SnappingDistance](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/types/snapping-distance.ts) = "25%" | Snapping activation distance. Can be specified as a percentage of the element size or in absolute values. The default value is `25%`. |
|
|
641
|
+
| snappingMethod | [SnappingMethod](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/snapping-method.ts) = [SnappingMethods.STANDART](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/snapping-methods.ts) | Snapping method. Default value is [SnappingMethods.STANDART](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/snapping-method.ts). [SnappingMethods.STANDART](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/snapping-method.ts) - Classic group visualization. [SnappingMethods.ADVANCED](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/snapping-method.ts) - A mask is applied to the viewport area so that the background is displayed underneath the attached group. |
|
|
642
|
+
| snapScrollToStart | boolean? = true | Determines whether the scroll will be anchored to the start of the list. Default value is "true". This property takes precedence over the snapScrollToEnd property. That is, if snapScrollToStart and snapScrollToEnd are enabled, the list will initially snap to the beginning; if you move the scroll bar to the end, the list will snap to the end. If snapScrollToStart is disabled and snapScrollToEnd is enabled, the list will snap to the end; if you move the scroll bar to the beginning, the list will snap to the beginning. If both snapScrollToStart and snapScrollToEnd are disabled, the list will never snap to the beginning or end. In the `spreadingMode=SpreadingModes.INFINITY` mode, the `snapScrollToStart` property is automatically disabled, since the list has no beginning or end. |
|
|
643
|
+
| snapScrollToEnd | boolean? = true | Determines whether the scroll will be anchored to the утв of the list. Default value is "true". That is, if snapScrollToStart and snapScrollToEnd are enabled, the list will initially snap to the beginning; if you move the scroll bar to the end, the list will snap to the end. If snapScrollToStart is disabled and snapScrollToEnd is enabled, the list will snap to the end; if you move the scroll bar to the beginning, the list will snap to the beginning. If both snapScrollToStart and snapScrollToEnd are disabled, the list will never snap to the beginning or end. In the `spreadingMode=SpreadingModes.INFINITY` mode, the `snapScrollToEnd` property is automatically disabled, since the list has no beginning or end. |
|
|
633
644
|
| snapToEndTransitionInstantOffset | number? = 0 | Sets the offset value; if the scroll area value is exceeded, the scroll animation will be disabled. Default value is "0". |
|
|
634
645
|
| scrollbarEnabled | boolean? = true | Determines whether the scrollbar is shown or not. The default value is "true". |
|
|
635
646
|
| scrollbarInteractive | boolean? = true | Determines whether scrolling using the scrollbar will be possible. The default value is "true". |
|
|
@@ -638,8 +649,11 @@ Inputs
|
|
|
638
649
|
| scrollbarThumbRenderer | TemplateRef<any> \| null = null | Scrollbar customization template. |
|
|
639
650
|
| scrollbarThumbParams | {[propName: string]: any;} \| null | Additional options for the scrollbar. |
|
|
640
651
|
| scrollBehavior | ScrollBehavior? = 'smooth' | Defines the scrolling behavior for any element on the page. The default value is "smooth". |
|
|
641
|
-
| scrollingSettings | [IScrollingSettings](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/interfaces/scrolling-settings.ts) = {frictionalForce: 0.035, mass: 0.005, maxDistance:
|
|
652
|
+
| scrollingSettings | [IScrollingSettings](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/interfaces/scrolling-settings.ts) = {frictionalForce: 0.035, mass: 0.005, maxDistance: 100000, maxDuration: 4000, speedScale: 10, optimization: true} | Scrolling settings. |
|
|
653
|
+
| scrollingOneByOne | boolean = false | Specifies whether to scroll one item at a time if true and the scrollToItem property is set. The default value is `false`. |
|
|
654
|
+
| spreadingMode | [SpreadingMode](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/enums/spreading-mode.ts) ='standart' | The order of list elements. Available values are `standard` and `infinity`. `normal` — list elements are ordered according to the collection sequence. `infinity` — list elements are ordered cyclically, forming an infinite list. When set to `infinity`, the `alignment` property is forced to the value `Alignments.CENTER`, the `scrollbarEnabled` property is forced to the `false`. The default value is `standard`. |
|
|
642
655
|
| trackBy | string? = 'id' | The name of the property by which tracking is performed. |
|
|
656
|
+
| zIndexWhenSelecting | string \| null = null | Defines the zIndex when a list item is selected. The default value is `null`. |
|
|
643
657
|
|
|
644
658
|
<br/>
|
|
645
659
|
|
|
@@ -647,6 +661,7 @@ Outputs
|
|
|
647
661
|
|
|
648
662
|
| Event | Type | Description |
|
|
649
663
|
|---|---|---|
|
|
664
|
+
| onSnapItem | [Id](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/types/id.ts) | Emit the component ID when an element crosses the alignment line specified by the snapToItemAlign property. |
|
|
650
665
|
| onItemClick | [IRenderVirtualListItem](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/models/render-item.model.ts) \| null | Fires when an element is clicked. |
|
|
651
666
|
| onScroll | ([IScrollEvent](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/interfaces/scroll-event.ts)) => void | Fires when the list has been scrolled. |
|
|
652
667
|
| onScrollEnd | ([IScrollEvent](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/interfaces/scroll-event.ts)) => void | Fires when the list has completed scrolling. |
|
|
@@ -690,18 +705,30 @@ Properties
|
|
|
690
705
|
|
|
691
706
|
<br/>
|
|
692
707
|
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
708
|
+
### [VirtualClickModule](https://github.com/DjonnyX/ng-virtual-list/blob/21.x/projects/ng-virtual-list/src/lib/directives/item-click/item-click.module.ts)
|
|
709
|
+
|
|
710
|
+
### Virtual click directive
|
|
711
|
+
|
|
712
|
+
To correctly handle interactive elements within a list, such as buttons, you need to use the VirtualClick directive.
|
|
713
|
+
|
|
714
|
+
```ts
|
|
715
|
+
import { NgVirtualListModule, VirtualClickModule } from 'ng-virtual-list';
|
|
716
|
+
|
|
717
|
+
@Component({
|
|
718
|
+
selector: 'example',
|
|
719
|
+
imports: [NgVirtualListModule, VirtualClickModule],
|
|
720
|
+
})
|
|
721
|
+
```
|
|
722
|
+
|
|
723
|
+
```html
|
|
724
|
+
<ng-template #itemRenderer let-data="data" let-config="config" let-api="api">
|
|
725
|
+
@if (data) {
|
|
726
|
+
<div virtualClick (onVirtualClick)="api.select(data.id, true)">
|
|
727
|
+
<span>{{data.name}}</span>
|
|
728
|
+
</div>
|
|
729
|
+
}
|
|
730
|
+
</ng-template>
|
|
731
|
+
```
|
|
705
732
|
|
|
706
733
|
## 🤝 Contributing
|
|
707
734
|
|