1.0.7 • Published 7 months ago

cui-virtual-list v1.0.7

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

CUI SolidJS NPM downloads NPM downloads JS gzip size

Demo

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
1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

11 months ago

1.0.0

11 months ago