Skip to content

Commit 6ef7a3b

Browse files
author
Guillaume Chau
committed
Updated doc
1 parent f502816 commit 6ef7a3b

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

README.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ import 'vue-virtual-scroller/dist/vue-virtual-scroller.css'
5151
<link rel="stylesheet" href="vue-virtual-scroller/dist/vue-virtual-scroller.css"/>
5252

5353
<script src="vue.js"></script>
54-
<script src="vue-virtual-scroller/dist/vue-virtual-scroller.js"></script>
54+
<script src="vue-virtual-scroller/dist/vue-virtual-scroller.min.js"></script>
5555
```
5656

57-
Install all the components:
57+
If Vue is detected, the plugin will be installed automatically. If not, install the component:
5858

5959
```javascript
6060
Vue.use(VueVirtualScroller)
6161
```
6262

63-
Use specific components:
63+
Or register it with a custom name:
6464

6565
```javascript
6666
Vue.component('virtual-scroller', VueVirtualScroller.VirtualScroller)
@@ -71,10 +71,12 @@ Vue.component('virtual-scroller', VueVirtualScroller.VirtualScroller)
7171
The virtual scroller has three main props:
7272

7373
- `items` is the list of items you want to display in the scroller. There can be several types of item.
74-
- `itemHeight` is the display height of the items in pixels used to calculate the scroll height and position. If it set to null (default value), it will use [variable height mode](#variable-height-mode).
74+
- `itemHeight` is the display height of the items in pixels used to calculate the scroll height and position. If it set to `null` (default value), it will use [variable height mode](#variable-height-mode).
7575
- `renderers` is a map of component definitions objects or names for each item type ([more details](#renderers)). If you don't define `renderers`, the scroller will use *scoped slots* ([see below](#scoped-slots)).
7676

77-
You need to set the size of the virtual-scroller element and the items elements (for example, with CSS). Unless you are using [variable height mode](#variable-height-mode), all items should have the same height to prevent display glitches.
77+
⚠️ You need to set the size of the virtual-scroller element and the items elements (for example, with CSS). Unless you are using [variable height mode](#variable-height-mode), all items should have the same height to prevent display glitches.
78+
79+
**It is strongly recommended to use functional components inside virtual-scroller since those are cheap to create and dispose.**
7880

7981
> The browsers have a height limitation on DOM elements, it means that currently the virtual scroller can't display more than ~500k items depending on the browser.
8082
@@ -99,7 +101,7 @@ Here is an example:
99101

100102
```html
101103
<virtual-scroller class="scroller" :items="items" item-height="42" content-tag="table">
102-
<template scope="props">
104+
<template slot-scope="props">
103105
<tr v-if="props.item.type === 'letter'" class="letter" :key="props.itemKey">
104106
<td>
105107
{{props.item.value}} Scoped
@@ -165,6 +167,26 @@ const items = [
165167
]
166168
```
167169

170+
## Buffer
171+
172+
You can set the `buffer` prop (in pixels) on the virtual-scroller to extend the viewport considered when determining the visible items. For example, if you set a buffer of 1000 pixels, the virtual-scroller will start rendering items that are 1000 pixels below the bottom of the scroller visible area, and will keep the items that are 1000 pixels above the top of the visible area.
173+
174+
The default value is `200`.
175+
176+
```html
177+
<virtual-scroller buffer="200" />
178+
```
179+
180+
## Pool Size
181+
182+
The `poolSize` prop (in pixels) is the size in pixels of the viewport pool. The computed 'visible' area can be computed step by step using this pool. This allows creating multiple row at once each in a while. For example, if you set a pool size of 2000 pixels, the rows will be grouped in pools of 2000 pixels height. When the user scrolls too far, the new batch of 2000px height is created, and so on. That way, the DOM isn't updated for each row, but in batches instead.
183+
184+
The default value is `2000`.
185+
186+
```html
187+
<virtual-scroller pool-size="2000" />
188+
```
189+
168190
## Customizing the tags
169191

170192
These are optional props you can use to change the DOM tags used in the virtual scroller:

0 commit comments

Comments
 (0)