cui-virtual-list
v1.0.7
Published
cui solid-js virtual list
Downloads
3
Readme
Demo
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,
}}
// can't be lacked important!!!
ref={props.ref}
>
<div> {new Array(props.item).fill(true).map(() => 'Row').join(" ")} Row {props.index}</div>
</div>
}
<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
# yarn
yarn add cui-virtual-list