Skip to content

Commit 08f1145

Browse files
committed
Update readme.
1 parent 7d597e7 commit 08f1145

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

README.md

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
<a href="https://vuejs.org/">
2+
<img src="https://img.shields.io/badge/vue-2.x-brightgreen.svg" alt="Vue version"/>
3+
</a>
14
<a href="https://npmjs.com/package/vue-virtual-scroll-list">
25
<img src="https://img.shields.io/npm/v/vue-virtual-scroll-list.svg?style=flat" alt="NPM version"/>
36
</a>
@@ -7,17 +10,14 @@
710
<a href="http://packagequality.com/#?package=vue-virtual-scroll-list">
811
<img src="http://npm.packagequality.com/shield/vue-virtual-scroll-list.svg">
912
</a>
10-
<a href="https://vuejs.org/">
11-
<img src="https://img.shields.io/badge/vue-2.x-brightgreen.svg" alt="Vue version"/>
12-
</a>
1313
<a href="https://github.com/tangbc/vue-virtual-scroll-list/blob/master/LICENSE">
1414
<img src="https://img.shields.io/github/license/tangbc/vue-virtual-scroll-list.svg" alt="MIT License"/>
1515
</a>
1616

1717

1818
## vue-virtual-scroll-list
1919

20-
> A vue (2.x) component that supports big data and infinite loading by using virtual scroll list.
20+
> If you are looking for a vue component which support big data list and high scroll performance, you are in the right place.
2121
2222
* Tiny and very very easy to use.
2323

@@ -55,29 +55,27 @@ npm install vue-virtual-scroll-list --save
5555
```vue
5656
<template>
5757
<div>
58-
<virtualList :size="40" :remain="8">
59-
<Item v-for="(item, index) of items" :item="item" :key="item.id" />
60-
</virtualList>
58+
<virtual-list :size="40" :remain="8">
59+
<item v-for="(item, index) of items" :key="item.id" />
60+
</virtual-list>
6161
</div>
6262
</template>
6363
6464
<script>
65-
import Item from '../item.vue'
65+
import item from '../item.vue'
6666
import virtualList from 'vue-virtual-scroll-list'
6767
6868
export default {
69-
name: 'demo',
7069
data () {
7170
return {
7271
items: [...]
7372
}
7473
},
75-
components: { Item, virtualList }
74+
components: { item, 'virtual-list': virtualList }
7675
}
7776
</script>
7877
```
7978

80-
The `<Item>` component is included inside but defined outside the `<virtualList>` component, we see that `<virtualList>` does **not** rely on the `<Item>` component, so you can use virtual-list with any component freely.
8179

8280
#### Using by script include:
8381

@@ -107,9 +105,9 @@ new Vue({
107105

108106
## Notice
109107

110-
* List `<Item/>` component or DOM frag using `v-for` must designate the `:key` property.
108+
* Must assign the `:key` property on `<item>` component or DOM frag with `v-for` directive.
111109

112-
* Consider use `box-sizing: border-box;` on `<Item/>` if you want absolutely correct scroll height.
110+
* Consider use `box-sizing: border-box` on `<item>` if you want absolutely correct scroll height.
113111

114112

115113
## Props type
@@ -118,30 +116,30 @@ new Vue({
118116

119117
*Prop* | *Type* | *Required* | *Description* |
120118
:--- | :--- | :--- | :--- |
121-
| size | Number || Each list item height, in variable height mode, this prop just use to calculate the virtual-list viewport height. |
119+
| size | Number || Each list item height, in variable height mode, this prop just use to calculate the virtual-list outside container viewport height. |
122120
| remain | Number || How many items should be shown in virtual-list viewport, so `size` and `remain` determine the outside container viewport height (size × remian). |
123121
| start | Number | * | Default value is `0`, the initial scroll start index. It must be integer and in the range of list index, if out of range it will be turned to `0` or the last one. |
124122
| bench | Number | * | Default value is equal to `remain`, unreached items count, not show in virtual-list viewport but exist in real DOM, the larger the bench, the higher the scroll performance will achieved. |
125123
| debounce | Number | * | **It's disabled by default**, milliseconds of using `debounce` function to ensure scroll event doesn't fire so often that it bricks browser performance. |
126124
| rtag | String | * | Default value is `div`, the virtual-list root element tag name, in all cases it's style is set to `display: block;` |
127125
| wtag | String | * | Default value is `div`, the virtual-list item wrapper element tag name, in all cases it's style is set to `display: block;` |
128-
| wclass | String | * | Default value is an empty string, the virtual-list item wrapper element class, has the same API with [`v-bind:class`](https://vuejs.org/v2/guide/class-and-style.html) |
126+
| wclass | String | * | Default value is an empty string, the virtual-list item wrapper element class, if assign this prop, you better **not** to change it's [CSS box model](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model). |
129127
| totop | Function | * | Called when virtual-list is scrolled to top, no param. |
130128
| tobottom | Function | * | Called when virtual-list is scrolled to bottom, no param. |
131129
| onscroll | Function | * | Called when virtual-list is scrolling, param: `(e, { offset, offsetAll, start, end })`. |
132130
| variable | Function or Boolean | * | For using virtual-list with variable height mode. If assign `Function`, this prop is a variable height getter function which is called with param: `(index)` when each item is ready to be calculated. If assign `Boolean`, virtual-list will get each item variable height by it's inline style height automatic. |
133131

134132
### About variable height
135133

136-
In variable height mode, prop `size` is still required. All the index variable height and scroll offset will be cached by virtual-list after the binary-search calculate, if you want to change anyone `<Item/>` height from data, you should call virtual-list's `updateVariable(index)` method to clear the offset cached, refer to [variable example](https://github.com/tangbc/vue-virtual-scroll-list/blob/master/examples/variable/variable.vue#L1) source for detail.
134+
In variable height mode, prop `size` is still required. All the index variable height and scroll offset will be cached by virtual-list after the binary-search calculate, if you want to change anyone `<Item/>` height from data, you should call virtual-list's `updateVariable(index)` method to clear the offset cache, refer to [variable example](https://github.com/tangbc/vue-virtual-scroll-list/blob/master/examples/variable/variable.vue#L1) source for detail.
137135

138136
If you are using `variable` assign by `Boolean`, **do not** set inline style height inside `<item/>` component, you must set inline style height on `<item/>` component outside directly, such as:
139137
```vue
140138
<template>
141139
<div>
142-
<virtualList :size="40" :remain="8" :variable="true">
143-
<Item v-for="item of items" :key="item.id" :style="{ height: item.height + 'px' }" />
144-
</virtualList>
140+
<virtual-list :size="40" :remain="8" :variable="true">
141+
<item v-for="item of items" :key="item.id" :style="{ height: item.height + 'px' }" />
142+
</virtual-list>
145143
</div>
146144
</template>
147145
```

0 commit comments

Comments
 (0)