Skip to content

Commit

Permalink
test on autosizer
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMarcMilletScality committed Mar 18, 2024
1 parent aa1e276 commit b9e241c
Showing 1 changed file with 35 additions and 33 deletions.
68 changes: 35 additions & 33 deletions src/lib/components/tablev2/TableCommon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,40 +48,42 @@ export const VirtualizedRows = <
listRef,
itemKey,
}: VirtualizedRowsType<DATA_ROW>) => (
<AutoSizer>
{({ height, width }) => {
return (
<List
height={height}
itemCount={rows.length} // how many items we are going to render
itemSize={convertRemToPixels(tableRowHeight[rowHeight])} // height of each row in pixel
width={width}
itemKey={itemKey}
itemData={rows}
ref={listRef}
onItemsRendered={({
visibleStartIndex,
visibleStopIndex,
overscanStopIndex,
}) => {
setHasScrollbar(
visibleStopIndex - visibleStartIndex < overscanStopIndex,
);
<div style={{ flex: '1 1 auto' }}>
<AutoSizer>
{({ height, width }) => {
return (
<List
height={height}
itemCount={rows.length} // how many items we are going to render
itemSize={convertRemToPixels(tableRowHeight[rowHeight])} // height of each row in pixel
width={width}
itemKey={itemKey}
itemData={rows}
ref={listRef}
onItemsRendered={({
visibleStartIndex,
visibleStopIndex,
overscanStopIndex,
}) => {
setHasScrollbar(
visibleStopIndex - visibleStartIndex < overscanStopIndex,
);

if (
onBottom &&
onBottomOffset != null &&
overscanStopIndex >= rows.length - 1 - onBottomOffset
) {
onBottom(rows.length);
}
}}
>
{RenderRow}
</List>
);
}}
</AutoSizer>
if (
onBottom &&
onBottomOffset != null &&
overscanStopIndex >= rows.length - 1 - onBottomOffset
) {
onBottom(rows.length);
}
}}
>
{RenderRow}
</List>
);
}}
</AutoSizer>
</div>
);

export const useTableScrollbar = () => {
Expand Down

0 comments on commit b9e241c

Please sign in to comment.