Conversation
|
Thanks for the PR and the detailed write-up! I think there's a simpler path here. The jumping happens because Column locking fights against that optimization. And with multi-span items, locking can create visible gaps (e.g., a span=2 item must start at the tallest column's height, leaving empty space in shorter columns). The simpler solution: if your items resize dynamically, use Think of it as:
|
Thanks for the reply @naqvitalha . We have tried using Perhaps another solution that could be considered is if we extend
Boolean values could still be supported for backward compatibility. Could you consider that approach?
Gaps with multi-span appear even in current implementation when items resize, because most of the time none of the items can fit the gap. It's evident in fixture app (ComplexMasonry) as well. Additionally, I believe small gap is better than items jumping between columns. |
Description
Fixes #2107
This PR prevents items from "jumping" between columns in the Masonry Layout when
optimizedItemArrangementis enabled. It ensures that resizing an item doesn't disrupt the user's visual flow by locking the column positions.Currently, when an item’s size changes, the Masonry algorithm recomputes the entire layout for all subsequent items. While this optimization helps fill gaps, it causes visible items to jump to different columns, causing a bad UX for end users.
To improve the UX, I've introduced a
lastLockedItemIndexwhich is the index of last engaged item. It ensures that all items up to that index retain their previously calculated column. Recomputation of columns would now only be allowed for items above that index (i.e. non-visible items), so the end user wouldn't notice it.Reviewers’ hat-rack 🎩
Screenshots or videos (if needed)
Tested in ComplexMasory in fixture app:
