T
TanStack16mo ago
generous-apricot

Dynamic Width + Manual Scrolling Re-mounts

Hello. I want to achieve the same effect as in Chrome DevTools > Performance tab. This means that when you hold Command (or Ctrl) and scroll, it should zoom into a certain point. I use the virtualizer.measure() API for this so the library can react to the width change. For some reason, it re-mounts elements that should be visible if I scroll quickly. The further to the right I scroll, the more noticeable the issue becomes. The first render after mounting is delayed, making the issue more apparent. Am I on the right track, or is there a better way to achieve this? https://codesandbox.io/p/sandbox/zoom-and-scroll-example-4443vy
1 Reply
eastern-cyan
eastern-cyan16mo ago
You can also use getItemKey that will trigger update https://codesandbox.io/p/sandbox/zoom-and-scroll-example-forked-ky5kdg?file=%2Fsrc%2Fcomponents%2FVirtualizedList.tsx%3A44%2C15
getItemKey: useCallback((index) => index, [zoomLevel]),
overscan: 10,
getItemKey: useCallback((index) => index, [zoomLevel]),
overscan: 10,
Elelemetns are added while you scroll that why this delay, i think you tweak it with overscan

Did you find this page helpful?