@@ -46,6 +46,27 @@ RxVirtualView is designed to work in combination with related directives:
46
46
47
47
### Show a widget when it's visible, otherwise show a placeholder
48
48
49
+ ``` typescript
50
+ import {
51
+ RxVirtualView ,
52
+ RxVirtualViewContent ,
53
+ RxVirtualViewObserver ,
54
+ RxVirtualViewPlaceholder ,
55
+ } from ' @rx-angular/template/virtual-view' ;
56
+ // Other imports...
57
+
58
+ @Component ({
59
+ selector: ' my-list' ,
60
+ imports: [RxVirtualView , RxVirtualViewContent , RxVirtualViewObserver , RxVirtualViewPlaceholder ],
61
+ templateUrl: ' ./my-list.component.html' ,
62
+ styleUrls: [' ./my-list.component.scss' ],
63
+ changeDetection: ChangeDetectionStrategy .OnPush ,
64
+ })
65
+ export class MyListComponent {
66
+ // Component code
67
+ }
68
+ ```
69
+
49
70
``` html
50
71
<!-- use the root node (html) for the IntersectionObserver -->
51
72
<div rxVirtualViewObserver [root] =" null" >
@@ -82,6 +103,27 @@ This will make sure you don't run into stuttery scrolling behavior and layout sh
82
103
This example demonstrates how to use RxVirtualView to optimize lists by only rendering the visible list items.
83
104
We are only rendering the ` item ` component when it's visible to the user. Otherwise, it gets replaced by an empty div.
84
105
106
+ ``` typescript
107
+ import {
108
+ RxVirtualView ,
109
+ RxVirtualViewContent ,
110
+ RxVirtualViewObserver ,
111
+ RxVirtualViewPlaceholder ,
112
+ } from ' @rx-angular/template/virtual-view' ;
113
+ // Other imports...
114
+
115
+ @Component ({
116
+ selector: ' my-list' ,
117
+ imports: [RxVirtualView , RxVirtualViewContent , RxVirtualViewObserver , RxVirtualViewPlaceholder ],
118
+ templateUrl: ' ./my-list.component.html' ,
119
+ styleUrls: [' ./my-list.component.scss' ],
120
+ changeDetection: ChangeDetectionStrategy .OnPush ,
121
+ })
122
+ export class MyListComponent {
123
+ // Component code
124
+ }
125
+ ```
126
+
85
127
``` html
86
128
<div rxVirtualViewObserver class =" container" >
87
129
@for (item of items; track item.id) {
0 commit comments