W3C home > Mailing lists > Public > www-style@w3.org > October 2011

Re: [css3-flexbox] resolving flexible lengths

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Sun, 16 Oct 2011 23:31:19 -0700
Message-ID: <CAAWBYDAWsivmH=kAa7gEJx16_kQT3-GzoLNg-x9u_u64tEw_6g@mail.gmail.com>
To: Ojan Vafai <ojan@chromium.org>
Cc: www-style@w3.org
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:45 GMT