cui-virtual-list-vue3
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

CUI-Virtual-List-Vue3

A simple vertical Virtual List based on vue3

Virtual-list NPM downloads NPM downloads JS gzip size

Props

// fixed height of container, choose between height/maxHeight
height?: number
// max height of container, choose between height/maxHeight
maxHeight?: number
// item estimated size, use to initialization content height
itemEstimatedSize: number
// prev or next number of items to show
overscan?: number,
// list data
items: any[]

Example

export const createArray = (count: number) => {
    return new Array(count).fill(true).map(() => 1 + Math.round(Math.random() * 20))
};

export const ListItem = (props: any) : JSXElement => {
    const style = {...props.style}
    return <div
        style={style}
        role="listitem"
        classList={{
            "ListItemOdd": props.index % 2 === 0,
            "ListItemEven": props.index % 2 === 1,
        }}
        >
        <div> {new Array(props.item).fill(true).map(() => 'Row').join(" ")} Row {props.index}</div>
    </div>
}

ListItem.displayName = 'ListItem'

<div style={{'250px', border: '1px solid #ccc'}}>
    <VirtualList height={250} items={createArray(10000)} itemEstimatedSize={20}>
        {ListItem}
    </VirtualList>
</div>

Install

# npm
npm install cui-virtual-list-vue3
# yarn
yarn add cui-virtual-list-vue3

Readme

Keywords

none

Package Sidebar

Install

npm i cui-virtual-list-vue3

Weekly Downloads

1

Version

1.0.4

License

MIT

Unpacked Size

29.8 kB

Total Files

8

Last publish

Collaborators

  • cqb325