Reference switcher
A proving-ground demo based on a compact reference layout: the same nine cards switch between fixed-column masonry and fixed-row masonry so the difference in packing direction is easy to see.
Columns are fixed, rows pack tight. Items flow into the shortest column, eliminating the gaps you would get with a regular grid.