-
-
Notifications
You must be signed in to change notification settings - Fork 415
fix(virtual-core): expand range in masonry layouts to catch items from all lanes #937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
View your CI Pipeline Execution ↗ for commit 88780cf.
☁️ Nx Cloud last updated this comment at |
|
I closed this temporarily because I was still hitting problems in my application, but I was able to verify that the bug was just in my application and not this PR. |
|
piecyk
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks @soren121 🥇
Fixes #936
Fixes #665
This PR resolves two issues related to items being "missed" (i.e. unexpectedly cut-off or not rendered) in masonry layouts.
The first problem is that
calculateRangewas not changed when we added support for masonry layouts. This function assumes that items are purely sequential in the layout: it finds an item close to the scroll offset, and expands forward until it finds an item that exceeds the window. Masonry layouts do not behave like this. Even though ourmeasurementsarray is one-dimensional, the view is two-dimensional. Items which are far apart inmeasurementsmay still be rendered side-by-side, and that needs to be accounted for.The solution I came up with is to expand the range in both directions until we've found every item that should be in-view in each lane. This feels somewhat naive, and perhaps there's a more performant solution, but I think for the majority of masonry layouts, it should perform just fine.
The second problem is in the same vein:
getTotalSizemisses some items because it's not always true that the last items in each lane will be the last N items inmeasurements(where N is the number of lanes.) This is becausemeasurementsis sorted by thestartposition, and if you have very uneven item sizes, theendpositions could be very different from each other. I changed this to work in a similar way: it scans from the bottom up until it's found end positions for all lanes, and then selects the maximum.Both of the issues can be seen in the reproduction link in #936.