Skip to content
This repository was archived by the owner on Nov 5, 2023. It is now read-only.

Commit 023f870

Browse files
committed
docs: improve the demo
1 parent ec5e794 commit 023f870

16 files changed

+1412
-144
lines changed

README.md

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,12 @@ npm istall vue-virtual-scroll-grid
3131
<Grid :length="1000" :pageSize="2" :pageProvider="pageProvider" class="grid">
3232
<!-- When the item is not loaded, a placeholder is rendered -->
3333
<template v-slot:placeholder="{ index, style }">
34-
<div class="item" :style="style">
35-
Placeholder {{ index }}
36-
</div>
34+
<div class="item" :style="style">Placeholder {{ index }}</div>
3735
</template>
3836
3937
<!-- Render a loaded item -->
4038
<template v-slot:default="{ item, style, index }">
41-
<div class="item" :style="style">
42-
{{ item }} {{ index }}
43-
</div>
39+
<div class="item" :style="style">{{ item }} {{ index }}</div>
4440
</template>
4541
</Grid>
4642
</template>
@@ -49,9 +45,9 @@ npm istall vue-virtual-scroll-grid
4945
import Grid from "vue-virtual-scroll-grid";
5046
5147
export default {
52-
name : "App",
53-
components: {Grid},
54-
setup : () => ({
48+
name: "App",
49+
components: { Grid },
50+
setup: () => ({
5551
// Return items for the given page after a 0-3 second randomly
5652
pageProvider: (pageNumber, pageSize) =>
5753
new Promise((resolve) =>
@@ -140,28 +136,39 @@ interface Props {
140136
// must be an integer and greater than or equal to 0.
141137
length: number;
142138
// The callback that returns a page of items as a promise.
143-
pageProvider: (pageNumber: number, pageSize: number) => Promise<unknown[]>
139+
pageProvider: (pageNumber: number, pageSize: number) => Promise<unknown[]>;
144140
// The number of items in a page from the item provider (e.g. a backend API),
145141
// must be an integer and greater than or equal to 0.
146142
pageSize: number;
147143
}
148144
```
149145

150-
## Available Scoped Slots
146+
## Available Slots
151147

152-
There are 2 scoped slots: `default` and `placeholder`. Both of them have the
153-
following slot props:
148+
There are 3 scoped slots: `default`, `placeholder` and `probe`.
154149

150+
Props of the `default` slot:
151+
152+
- `item`: the loaded item that is used for rendering your item
153+
element/component.
155154
- `index`: the index of current item within the list.
156155
- `style`: the style object provided by the library that need to be set on the
157156
item element/component.
158157

159-
The `default` slot has an extra prop `item`, which is the loaded item that is
160-
used for rendering your item element/component.
158+
Props of the `placeholder` slot:
159+
160+
- `index`: the index of current item within the list.
161+
- `style`: the style object provided by the library that need to be set on the
162+
item element/component.
161163

162164
The `placeholder` slot is optional. If missing, the space of unloaded items will
163165
be blank until they are loaded.
164166

167+
The `probe` slot has no prop. It is used to measure the visual size of grid
168+
item. If not provided, you must set a fixed height to `grid-template-rows` on
169+
your CSS grid, or a fixed `height` on your item element/component, e.g. `200px`.
170+
Otherwise, the view won't be rendered properly.
171+
165172
## Development
166173

167174
- Setup `npm install`

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
66
<title>Vue Virtual Scroll Grid Demo</title>
7-
<script type="module" src="/src/main.ts"></script>
7+
<link rel="stylesheet" href="/src/demo/reset.css">
8+
<script type="module" src="/src/demo/main.ts"></script>
89
</head>
910
<body></body>
1011
</html>

0 commit comments

Comments
 (0)