#IS the scroll being controlled?

7 messages · Page 1 of 1 (latest)

peak rose
#

When using the library, the scrolling is not smooth and does not seem native anymore. Is the scroll controlled by the lib ?

radiant surge
#

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.

ruby escarp
#

My height is estimated, and could be calculated up front, but scrolling using virtualizer.scrollToOffset is slow compared to native scroll

twin ridge
#

@ruby escarp are you setting ref={virtualizer.measureElement} ?

ruby escarp
#
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