An open API service indexing awesome lists of open source software.

https://github.com/biubiukam/better-scrollbar

自定义滚动条、滚动容器、虚拟滚动
https://github.com/biubiukam/better-scrollbar

customizable react scroll scrollbar scrolling scrollview

Last synced: about 1 year ago
JSON representation

自定义滚动条、滚动容器、虚拟滚动

Awesome Lists containing this project

README

          

# better-scrollbar

![NPM License](https://img.shields.io/npm/l/better-scrollbar)
![NPM Version](https://img.shields.io/npm/v/better-scrollbar)
[![Coverage Status](https://coveralls.io/repos/github/kampiu/better-scrollbar/badge.svg?branch=master)](https://coveralls.io/github/kampiu/better-scrollbar?branch=master)

Highly customizable, high-performance virtual list for big data rendering.

Feel free to provide feedback if there are any issues, and promptly synchronize problem handling.

## Installation
```bash
npm install better-scrollbar --save
```

## Usage

```javascript
import React, { Component } from "react"
import ScrollBar from "better-scrollbar"
import "better-scrollbar/dist/BetterScrollbar.min.css"

class App extends Component {
render() {
return (

Some great content...



)
}
}
```

The `` component is completely customizable. Check out the following code:

```javascript
import React, { Component } from "react"
import ScrollBar from "better-scrollbar"
import "better-scrollbar/dist/BetterScrollbar.min.css"

class CustomScrollBar extends Component {
render() {
return (

)
}
}
```

### If you are a tree level structure, you can use the following code:

```tsx
import React from "react"
import ScrollBar from "better-scrollbar"
import "better-scrollbar/dist/BetterScrollbar.min.css"

interface Node {
id: string
name: string
next?: Array
}

const renderList = (props: Node): Array => {
const component =

{ props.name }

const nodesList = [component]

if (props?.next && props?.next) {
props?.next?.map((node) => nodesList.push(...renderList(node)))
}
return nodesList
}

export default () => {
const tree: Node = {id: "1", name: "demo"}
return (



{ renderList(tree) }


)
}
```

## Examples

Run the simple example:
```bash
# Make sure that you've installed the dependencies
npm install
npm run site:dev
```

## License

MIT