1
0
Fork 0
mirror of synced 2024-07-06 15:00:49 +12:00

Improve grid row inversion index calculation

This commit is contained in:
Andrew Kingston 2023-06-19 17:54:06 +01:00
parent 5350cdf346
commit dda4987848

View file

@ -111,14 +111,19 @@ export const deriveStores = context => {
[height, rowHeight, scrollTop],
([$height, $rowHeight, $scrollTop]) => {
const offset = $scrollTop % $rowHeight
// Compute the last row index with space to render popovers below it
const minBottom =
$height - ScrollBarSize * 3 - MaxCellRenderHeight + offset
return Math.floor(minBottom / $rowHeight)
const lastIdx = Math.floor(minBottom / $rowHeight)
// const maxCellRenderRows = Math.ceil(MaxCellRenderHeight / $rowHeight)
// const topIdx = $visualRowCapacity - maxCellRenderRows - 2
// const bottomIdx = maxCellRenderRows + 1
// return Math.max(topIdx, bottomIdx)
// Compute the first row index with space to render popovers above it
const minTop = MaxCellRenderHeight + offset
const firstIdx = Math.ceil(minTop / $rowHeight)
// Use the greater of the two indices so that we prefer content below,
// unless there is room to render the entire popover above
return Math.max(lastIdx, firstIdx)
}
)