PositionManager
The internal segment tree exposed for advanced use cases. Stores row heights and answers prefix-sum queries in O(log n).
ts
import { PositionManager } from 'vue-virtual-scroller-kit'
const manager = new PositionManager(
10_000, // item count
50, // uniform estimated height (or a function (index) => number)
)Use PositionManager when building completely custom virtualised layouts that don't fit the provided components.
Methods
totalSize
Total height of all items.
getOffset(index)
Pixel offset of item i = sum of heights [0..i-1].
getHeight(index)
Stored height of item i.
findIndex(scrollTop)
First item index visible at scrollTop.
set(index, height)
Update measured height, O(log n).
ts
manager.totalSize // total height of all items
manager.getOffset(index) // pixel offset of item i = sum of heights[0..i-1]
manager.getHeight(index) // stored height of item i
manager.findIndex(scrollTop) // first item index visible at scrollTop
manager.set(index, height) // update measured height, O(log n)