Replies: 1 comment 2 replies
-
If I understand your case correctly, you can do something like what this example was doing. Notice how I capture the known size in the You need to pay some attention on what's going on in the initial render (since you will receive Let me know if this is what you have in mind. It can be made more accessible (or, at least, documented, happy to accept a PR). P.S. the example was removed because beautiful dnd is in maintenance mode, but the idea for the height preserving itself is still valid. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I’m trying to improve the UX around placeholder rendering while items are loading. All item heights are dynamic, and their loading only begins once they're visible.
In discussion #1083, the topic came up around scroll up jumps when loading content with an unknown height. What I’m trying to do is at least make it so that if an item jumps once (when loading finishes), it doesn’t jump again the next time it’s shown as a placeholder.
To do that, I’d need a way to access the measured height that Virtuoso already knows about after it renders the full item, so I can reuse that same height next time I render a placeholder for that index. Right now, I’d have to measure it myself via getBoundingClientRect, but it feels wasteful since Virtuoso already has this data internally.
Would it be possible to expose something like
getItemHeight(index)
or anonItemMeasured(index, height)
callback?I understand the internal measurement logic is meant to be abstracted away, but this would go a long way toward avoiding layout shifts and improving the overall UX using Virtuoso. I saw that Tanstack Virtual for example exposes an array of
measurementsCache
(which isn't perfect because it also takes the estimated size into account), but I'd really prefer to stick with Virtuoso.Happy to provide more details or pitch in with a PR if needed.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions