Home

Awesome

vue-virtual-waterfall

A Vue 3 virtual waterfall component

npm

中文文档

Example

Usage

pnpm add @lhlyu/vue-virtual-waterfall

import { VirtualWaterfall } from '@lhlyu/vue-virtual-waterfall'
import VueVirtualWaterfall from '@lhlyu/vue-virtual-waterfall'

app.use(VueVirtualWaterfall)

<template>
    <VirtualWaterfall :items="items" :calcItemHeight="calcItemHeight">
        <template #default="{ item }: { item: ItemOption }">
            <div class="card">
                <img :src="item.img" />
            </div>
        </template>
    </VirtualWaterfall>
</template>

demo

Attention!!!

The VirtualWaterfall component wants to implement a virtual list, and the container that wraps it must indicate a fixed height. The scrolling event can be bound to this container. If this component is hung under the body, the height of the body also needs to be specified. The scrolling event can be bound to the window

Documentation

FieldTypeDefaultDescription
virtualbooleantrueEnable virtual list
rowKeystring'id'Key for v-for
gapnumber15Gap between each item
paddingnumber or string15 or '15px 15px'Container's padding
preloadScreenCount[number, number][0, 0]Preload screen count [above, below]
itemMinWidthnumber220Minimum width for each item
maxColumnCountnumber10Maximum number of columns
minColumnCountnumber2Minimum number of columns
itemsany[][]Data
calcItemHeight(item: any, itemWidth: number) => number(item: any, itemWidth: number) => 250Method to calculate item height
EventTypeDescription
default{ item: any, index: number }Custom default content