1
0
Fork 0
mirror of synced 2024-10-05 12:34:50 +13: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],
([$height, $rowHeight, $scrollTop]) => { ([$height, $rowHeight, $scrollTop]) => {
const offset = $scrollTop % $rowHeight const offset = $scrollTop % $rowHeight
// Compute the last row index with space to render popovers below it
const minBottom = const minBottom =
$height - ScrollBarSize * 3 - MaxCellRenderHeight + offset $height - ScrollBarSize * 3 - MaxCellRenderHeight + offset
return Math.floor(minBottom / $rowHeight) const lastIdx = Math.floor(minBottom / $rowHeight)
// const maxCellRenderRows = Math.ceil(MaxCellRenderHeight / $rowHeight) // Compute the first row index with space to render popovers above it
// const topIdx = $visualRowCapacity - maxCellRenderRows - 2 const minTop = MaxCellRenderHeight + offset
// const bottomIdx = maxCellRenderRows + 1 const firstIdx = Math.ceil(minTop / $rowHeight)
// return Math.max(topIdx, bottomIdx)
// 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)
} }
) )