Skip to content

Commit c72083e

Browse files
committed
Fix #4
1 parent cb42aaa commit c72083e

File tree

5 files changed

+29
-7
lines changed

5 files changed

+29
-7
lines changed

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ You need to set the size of the virtual-scroller element and the items elements
120120
121121
## Renderers
122122

123-
The optional `renderers` prop is an object containing a component definition for each possible value of the item type. If you don't set this prop, [scoped slots](#scoped-slots) will be used instead. **The component definition must have an `item` prop, that will get the item object to render in the scroller.**
123+
The optional `renderers` prop is an object containing a component definition for each possible value of the item type. If you don't set this prop, [scoped slots](#scoped-slots) will be used instead. **The component definition must have an `item` prop, that will get the item object to render in the scroller.** It will also receive an `index` prop.
124124

125125
There are additional props you can use:
126126

@@ -133,7 +133,7 @@ There are additional props you can use:
133133

134134
Alternatively, you can use [scoped slots](https://vuejs.org/v2/guide/components.html#Scoped-Slots) instead of `renderers`. This is active when you don't define the `renderers` prop on the virtual scroller.
135135

136-
The scope will contain the row's item in the `item` attribute, so you can write `scope="props"` and then use `props.item`.
136+
The scope will contain the row's item in the `item` attribute, so you can write `scope="props"` and then use `props.item`. It will also have an `index` attribute.
137137

138138
Here is an example:
139139

@@ -205,6 +205,24 @@ If you set `contentTag` to `'table'`, the actual result in the DOM will look lik
205205
</div>
206206
```
207207

208+
## Slots
209+
210+
There are 4 slots you can use to inject things inside the scroller (it may be usefull to add a `thead` or `tbody`):
211+
212+
```html
213+
<main>
214+
<slot name="before-container"></slot>
215+
<container>
216+
<slot name="before-content"></slot>
217+
<content>
218+
<!-- Your items here -->
219+
</content>
220+
<slot name="after-content"></slot>
221+
</container>
222+
<slot name="after-container"></slot>
223+
</main>
224+
```
225+
208226
# Example
209227

210228
```html

dist/vue-virtual-scroller.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11

2-
.virtual-scroller[data-v-62bbe8ac]:not(.page-mode) {
2+
.virtual-scroller[data-v-467266c7]:not(.page-mode) {
33
overflow-y: auto;
44
}
5-
.item-container[data-v-62bbe8ac] {
5+
.item-container[data-v-467266c7] {
66
box-sizing: border-box;
77
width: 100%;
88
overflow: hidden;
99
}
10-
.items[data-v-62bbe8ac] {
10+
.items[data-v-467266c7] {
1111
width: 100%;
1212
}
1313

0 commit comments

Comments
 (0)