10000 docs(template): add import statements for virtual-view by Karnaukhov-kh · Pull Request #1848 · rx-angular/rx-angular · GitHub
[go: up one dir, main page]

Skip to content

docs(template): add import statements for virtual-view #1848

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions apps/docs/docs/template/virtual-view-directive.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,27 @@ RxVirtualView is designed to work in combination with related directives:

### Show a widget when it's visible, otherwise show a placeholder

```typescript
import {
RxVirtualView,
RxVirtualViewContent,
RxVirtualViewObserver,
RxVirtualViewPlaceholder,
} from '@rx-angular/template/virtual-view';
// Other imports...

@Component({
selector: 'my-list',
imports: [RxVirtualView, RxVirtualViewContent, RxVirtualViewObserver, RxVirtualViewPlaceholder],
templateUrl: './my-list.component.html',
styleUrls: ['./my-list.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MyListComponent {
// Component code
}
```

```html
<!-- use the root node (html) for the IntersectionObserver -->
<div rxVirtualViewObserver [root]="null">
Expand Down Expand Up @@ -82,6 +103,27 @@ This will make sure you don't run into stuttery scrolling behavior and layout sh
This example demonstrates how to use RxVirtualView to optimize lists by only rendering the visible list items.
We are only rendering the `item` component when it's visible to the user. Otherwise, it gets replaced by an empty div.

```typescript
import {
RxVirtualView,
RxVirtualViewContent,
RxVirtualViewObserver,
RxVirtualViewPlaceholder,
} from '@rx-angular/template/virtual-view';
// Other imports...

@Component({
selector: 'my-list',
imports: [RxVirtualView, RxVirtualViewContent, RxVirtualViewObserver, RxVirtualViewPlaceholder],
templateUrl: './my-list.component.html',
styleUrls: ['./my-list.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class MyListComponent {
// Component code
}
```

```html
<div rxVirtualViewObserver class="container">
@for (item of items; track item.id) {
Expand Down
Loading
0