Antin Harasymiv
Mar 9, 2019 · 1 min read

Good question, I was a little vague sorry.

So targetHeight here is whatever row height we are hoping for. Eg in my examples for this post we were aiming to have each row be 180 pixels tall. You’d match this with the height used in the layout algorithm.

The 3 / 2 in the calculation comes from the fact that many photos are landscape with that aspect ratio (although with smartphones that’s changing, more often 4 / 3 now).

7 / 10 was a magic number with no great reason other than after testing the layout estimates on about 100 peoples’ collections it was the average of how wrong a super naive estimate was (eg 3 / 2 * photoCount * targetHeight). Ie, the estimate was usually about 30% too big so that brought it closer.

Truthfully though the estimate here doesn’t really matter, it’s just placeholder space, and we found that because we can adjust the placeholder to the real layout within a single animation frame (as described later in the blog) all that matters is it is vaguely indicative so the scroll bar looks about right.

I think we could probably just use photoCount * targetHeight and nobody would tell the difference.

    Antin Harasymiv

    Written by

    UX Engineer @Google