Re: [css-grid] Auto-placement algorithm sparse doubt

On Thu, Jun 26, 2014 at 2:20 PM, Manuel Rego Casasnovas <rego@igalia.com> wrote:
>
> Hi,
>
> I've a doubt regarding auto-placement algorithm [1].
>
> Imagine that we have a 3x3 grid without grid-auto-flow property defined.
> This means that the grid grows in the row direction when needed, and
> that the auto-placement algorithm is *sparse*.
>
> The HTML would be something like this:
> <div style="display: grid; grid-template-rows: 100px 100px 100px;
> grid-template-columns: 100px 100px 100px;">
>   <div>A</div>
>   <div style="grid-row: span 2; grid-column: span 2;">B</div>
>   <div>C</div>
> </div>
>
> Let's review the values of the auto-placement cursor.
>
> 1) Initially it's set to 1/1.
> 2) Then we place "A" item in the 1/1 position. The cursor is still 1/1.
> 3) "B" is placed in the 1/2 position (taking 1/2, 1/3, 2/2 and 2/3
> cells). The cursor is set to 1/2.
> 4) Finally "C" is placed in 2/1.
>
> The result will be like in the following diagram:
>
> -------------
> | A | B | B |
> -------------
> | C | B | B |
> -------------
> |   |   |   |
> -------------
>
> I guess that in this case, we can consider that elements appear
> out-of-order (which shouldn't happen in sparse mode).
>
> However, I'm wondering if in step 3), the auto-placement cursor should
> be set to 2/3 (the last occupied cell) instead of 1/2 (the first one).
> In that case "C" will be placed in 3/1.
> And the result would be something like this:
>
> -------------
> | A | B | B |
> -------------
> |   | B | B |
> -------------
> | C |   |   |
> -------------
>
> This situation seems to follow sparse concept better, and items appear
> in the right order.
>
> If this is right, probably the auto-placement algorithm wording should
> be modified to specify this.
>
> What would be the right result?

You got it right - the algorithm does require the first behavior you illustrate.

I'd prefer not to change it, however.  The current behavior isn't
quite "out of order" - that ordering is used for comic panels fairly
regularly, for example.

~TJ

Received on Thursday, 26 June 2014 21:37:31 UTC