-
Notifications
You must be signed in to change notification settings - Fork 11
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
Adding additional items to the layout ruins the order #4
Comments
yes, order will break if more items added to array. |
@HandsomeMedia @yyynnn good point... it's a short coming of what I presented here... one thought is to re-order the "whole array" (all items from a DB for example, before loading any content) and only show in sets of 20 items at a time, for example, using a "show more". I dunno... just talking out loud at the moment... |
So i decided to drop support for masonry grid at work, cuz it is simply an anti-pattern. |
@HandsomeMedia @yyynnn This is not how you approach a solution based on this nice implementation. For your use-cases, you need to think different regards pagination. For pagination you need to structure your data in different way. I assume that you both have an array of items that get concat-ed with the new chunk of data once you reach the bottom (or click "More") in the page. But the correct way to structure your data is to have an array of arrays. [
[...] // first pagination data chunk,
[...] // second pagination data chunk
] When you want to add the data you need to add a whole array that contains the new chunk.. And then you can render the inner array as columns-container that reorder it's own data. That way you won't need to re-order the whole data that have been re-ordered. So for pagination on page 2 you'll have two columns-container (each one has it's own data). You can use |
My friend found a leak in this implementation that I suggested which may not show as expected. |
When using, for example, a "show more" button at the bottom of the masonry layout, and then AJAX loading additional items in, the original items all get shuffled out of place.
Perhaps this is a limitation of using the multicolumn layout? A possible work-around might be to reorder all images together, then remove and re-add all items? That seems very inefficient and could cause paint/resource issues though. Any thoughts?
The text was updated successfully, but these errors were encountered: