2026-07-12 02:03:28 +08:00
|
|
|
name: VirtualScroll
|
|
|
|
|
|
2026-07-12 13:00:02 +08:00
|
|
|
purpose: Variable-height virtual scrolling utility used by List and DataGrid.
|
2026-07-12 02:03:28 +08:00
|
|
|
|
|
|
|
|
factory:
|
|
|
|
|
signature: VirtualScroll(options)
|
|
|
|
|
options:
|
|
|
|
|
itemHeight: Optional fixed initial item height.
|
|
|
|
|
|
|
|
|
|
methods:
|
|
|
|
|
reset: Initialize a new list and return its first render window.
|
|
|
|
|
init: Measure initial data and invoke refresh callback.
|
|
|
|
|
update: Measure one rendered item.
|
|
|
|
|
calc: Return paddings, renderedList, and listStartIndex for current scroll position.
|
|
|
|
|
|
|
|
|
|
rules:
|
|
|
|
|
- Treat this as an internal UI utility unless implementing a virtualized component.
|
|
|
|
|
- Call update after each rendered row can be measured.
|
|
|
|
|
|
2026-07-18 11:44:16 +08:00
|
|
|
examples:
|
|
|
|
|
basic: |
|
|
|
|
|
const virtual = VirtualScroll({ itemHeight: 40 })
|
|
|
|
|
virtual.reset(rows, container)
|
|
|
|
|
virtual.init(rows, () => refresh())
|
|
|
|
|
const view = virtual.calc(container, rows)
|
|
|
|
|
|
|
|
|
|
tests:
|
|
|
|
|
- ../components/base/List.test.html
|
|
|
|
|
- ../components/data/DataGrid.test.html
|