1.0.4 • Published 4 months ago

cui-virtual-list-vue3 v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
4 months ago

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
1.0.4

4 months ago

1.0.3

4 months ago

1.0.2

4 months ago

1.0.1

5 months ago

1.0.0

5 months ago