virtuallist-antd
仓库(github): https://github.com/crawler-django/virtuallist-antd
版本更新记录(update detail): https://github.com/crawler-django/virtuallist-antd/blob/master/update.md
virtualList for antd-table, 实现 antd-table 的虚拟列表, antd-table 无限滚动, infinite scrolling for antd-table. 支持 antd 树形表格, antd 版本要在 4.17.0 及以上, virtuallist-antd 要再 0.6.3 及以上. (support tree data, after antd v4.17.0, after virtuallist-antd v0.6.3)
-
已经支持 4.0 的 antd-table.(4.x ---- v0.3.0 后, 3.x ---- v0.2.8.)
(support antdv4. 4.x --- ^v0.3.0, 3.x --- v0.2.8. 3.x not updated)
-
你可以像平常一样在 columns 里使用 fixed
(u can use fixed as usual)
-
支持进行条件搜索 变更数据.
(support search data as usual)
-
目前用了节流 - 60ms 在滚动的时候刷新窗口
(use throttle, 60ms)
-
支持分页, calc().
(support pagination, support scrolly for calc())
-
只支持纵向虚拟列表.
(only support vertical virtuallist)
-
此组件会计算第一行的高度, 并且以第一行的高度为准来固定每行的高度. 组件有自带的 css, 会使每行的 td 不会换行.
(this component will calculate first line's height and amend following each line's height based on it. It has its own css, which prevents each line's TD from wrapping (td do not wrap))
example
complex example
Install
npm install --save virtuallist-antd
Usage
import React, { useMemo } from 'react'
import ReactDom from 'react-dom'
import { VList } from 'virtuallist-antd'
import { Table } from 'antd'
function Example(): JSX.Element {
const dataSource = [...]
const columns = [...]
const rowkey = 'xxx'
const vComponents = useMemo(() => {
return VList({
height: 1000
})
}, [])
return (
<Table
dataSource={dataSource}
columns={columns}
rowKey={rowKey}
scroll={{
y: 1000 // 滚动的高度, 可以是受控属性。 (number | string) be controlled.
}}
components={vComponents}
/>
)
}
ReactDom.render(<Example />, dom)
VList
VList({
height: number | string,
onReachEnd: () => void,
onScroll: () => void,
vid: string,
resetTopWhenDataChange: boolean,
})
VList returns: {
table: VTable,
body: {
wrapper: VWrapper,
row: VRow,
cell: VCell,
}
}
api
import { scrollTo } from 'virtuallist-antd'
scrollTo({
row: number,
y: number,
vid: string,
})
License
MIT © crawler-django