Re: [css3-flexbox] resolving flexible lengths

On Sun, Oct 16, 2011 at 6:07 PM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> In other words, doing either first is bad.  I'm trying to figure out
> how to explicitly phrase the "correct" way to do this, so you always
> find a space-filling and non-overflowing situation when one exists.

Got it, I think.  At least, it works now in my JS impl of the algorithm.

Basically, it goes like this:

1. Set the initial set of max and min violators both to empty sets.
2. Fix any max constraint violations, if they exist.
3. Fix any min constraint violations, if they exist.
4. If the old set of min violators is different from the ones that
were just fixed, re-fix the max violations (holding the min violations
steady, return the old max violations to flexibility and rerun the
distribution+detection+fixing algorithm).
5. If the old set of max violators is different from the ones that
were just fixed, re-fix the min violations (ditto, appropriately
altered).
6. Cycle between 3 and 4 until neither of them produce any new fixes.

Attached is the file with my JS impl, if my summarized algorithm above
was unclear.  (Note that the JS impl doesn't check for invalid data.
Alter at your own risk.)

This is, unfortunately, a "cycle until a steady state is reached" sort
of situation, but the state is very minimal and doesn't require any
sort of layout to compute.

~TJ

Received on Monday, 17 October 2011 06:32:38 UTC