#IS the scroll being controlled?
7 messages · Page 1 of 1 (latest)
This is due to element’s height being dynamic. There is no way to calculate the total height for the virtualizer upfront.
I use it to display a grid list of icons and I truncate their names so all elements are equal in height and therefore the total height is calculated upfront and scroll works normally.
My height is estimated, and could be calculated up front, but scrolling using virtualizer.scrollToOffset is slow compared to native scroll
@ruby escarp are you setting ref={virtualizer.measureElement} ?
const virtualizer = useVirtualizer({
enabled: isEnabled,
count: rows.length,
getScrollElement: () => ganttElements.listRows,
estimateSize: useCallback(
// rows[index] can be undefined when creating a new item
(index) => getScaledRowHeight(rows[index]?.type ?? 'task', prefs.fontSize),
[prefs.fontSize, rows]
),
getItemKey: useCallback(
(index) => {
const row = rows[index];
return `${row.type}-${row.targetId}-${row.rootGroupId}`;
},
[rows]
),
rangeExtractor,
overscan: 25,
});
Usiong estimateSize instead
@twin ridge