Skip to content
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

Masonry component [WIP] #618

Merged
merged 11 commits into from
Mar 27, 2017
Merged

Masonry component [WIP] #618

merged 11 commits into from
Mar 27, 2017

Conversation

bvaughn
Copy link
Owner

@bvaughn bvaughn commented Mar 20, 2017

Demo video: https://t.co/KquWlIIBJe

Overview

This component efficiently displays arbitrarily positioned cells using windowing techniques. Cell position is determined by an injected cellPositioner property. Windowing is vertical; this component does not support horizontal scrolling.

Rendering:

Rendering occurs in two phases:

  1. First phase uses estimated cell sizes (provided by the cache) to determine how many cells to measure in a batch. Batch size is chosen using a fast, naive layout algorithm that stacks images in order until the viewport has been filled. After measurement is complete (componentDidMount or componentDidUpdate) this component evaluates positioned cells in order to determine if another measurement pass is required (eg if actual cell sizes were less than estimated sizes). All measurements are permanently cached (keyed by keyMapper) for performance purposes.
  2. Second phase uses the external cellPositioner to layout cells. At this time the positioner has access to cached size measurements for all cells. The positions it returns are cached by Masonry for fast access later. Phase one is repeated if the user scrolls beyond the current layout's bounds. If the layout is invalidated due to eg a resize, cached positions can be cleared using recomputeCellPositions().

Animation constraints:

  • Simple animations are supported (eg translate/slide into place on initial reveal).
  • More complex animations are not (eg flying from one position to another on resize).

Layout constraints:

  • This component supports multi-column layout.
  • The height of each item may vary.
  • The width of each item must not exceed the width of the column it is "in". (Items may not span multiple columns.)
  • The left position of all items within a column must align.

@bvaughn bvaughn merged commit 7e241ba into master Mar 27, 2017
@bvaughn bvaughn deleted the masonry branch March 27, 2017 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant