Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
robinscholz committed Oct 25, 2022
2 parents 0e7e580 + 24747b6 commit 1639646
Show file tree
Hide file tree
Showing 19 changed files with 268 additions and 66 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vueuse/monorepo",
"version": "9.3.1",
"version": "9.4.0",
"private": true,
"packageManager": "pnpm@7.6.0",
"description": "Collection of essential Vue Composition Utilities",
Expand Down
2 changes: 1 addition & 1 deletion packages/components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vueuse/components",
"version": "9.3.1",
"version": "9.4.0",
"description": "Renderless components for VueUse",
"author": "Jacob Clevenger<https://github.com/wheatjs>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vueuse/core",
"version": "9.3.1",
"version": "9.4.0",
"description": "Collection of essential Vue Composition Utilities",
"author": "Anthony Fu <https://github.com/antfu>",
"license": "MIT",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/useVirtualList/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export const UseVirtualList = defineComponent<UseVirtualListProps>({

const { list, containerProps, wrapperProps } = useVirtualList(listRef, props.options)

containerProps.style.height = props.height || '300px'
typeof containerProps.style === 'object' && !Array.isArray(containerProps.style) && (containerProps.style.height = props.height || '300px')

return () => h('div',
{ ...containerProps },
[
Expand Down
30 changes: 29 additions & 1 deletion packages/core/useVirtualList/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ const { list, containerProps, wrapperProps } = useVirtualList(
| State | Type | Description |
|------------|----------|-------------------------------------------------------------------------------------------------|
| itemHeight | `number` | ensure that the total height of the `wrapper` element is calculated correctly.* |
| itemWidth | `number` | ensure that the total width of the `wrapper` element is calculated correctly.* |
| overscan | `number` | number of pre-rendered DOM nodes. Prevents whitespace between items if you scroll very quickly. |

\* The `itemHeight` must be kept in sync with the height of each row rendered. If you are seeing extra whitespace or jitter when scrolling to the bottom of the list, ensure the `itemHeight` is the same height as the row.
\* The `itemHeight` or `itemWidth` must be kept in sync with the height of each row rendered. If you are seeing extra whitespace or jitter when scrolling to the bottom of the list, ensure the `itemHeight` or `itemWidth` is the same height as the row.

### Reactive list

Expand Down Expand Up @@ -63,6 +64,33 @@ const { list, containerProps, wrapperProps } = useVirtualList(
</template>
```

### Horizontal list

```typescript
import { useVirtualList } from '@vueuse/core'

const allItems = Array.from(Array(99999).keys())

const { list, containerProps, wrapperProps } = useVirtualList(
allItems,
{
itemWidth: 200,
},
)
```

```html
<template>
<div v-bind="containerProps" style="height: 300px">
<div v-bind="wrapperProps">
<div v-for="item in list" :key="item.index" style="width: 200px">
Row: {{ item.data }}
</div>
</div>
</div>
</template>
```

## Component Usage

```html
Expand Down

0 comments on commit 1639646

Please sign in to comment.