Skip to content

Commit 38b1e3e

Browse files
committed
Apply Alex's suggestion about negative flexibility being scaled by flex-basis, so things will shrink more proportionally.
1 parent 53950c1 commit 38b1e3e

2 files changed

Lines changed: 52 additions & 48 deletions

File tree

css3-flexbox/Overview.html

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,30 +2531,30 @@ <h3 id=resolve-flexible-lengths><span class=secno>9.7. </span> Resolving
25312531
<li> <strong>Distribute free space proportional to flexibility.</strong>
25322532
If the sign of the free space matches the sign of the flexibility,
25332533
distribute the free space to each flexible item's main size in proportion
2534-
to the item's flexibility.
2535-
<div class=issue>
2536-
<p>Growing and shrinking from flex basis should use different formulas
2537-
for space distribution.</p>
2538-
2539-
<p>Grow proportional to <em> flexibility</em>. Items with equal
2540-
flexibility grow by same absolute amount.</p>
2541-
2542-
<pre>
2543-
free-space = available-space - sum(flex-basis)
2544-
main-size = flex-basis + free-space * positive-flex / sum(positive-flex)</pre>
2545-
2546-
<p>Shrink proportional to its <em> flexibility and flex-basis.</em>
2547-
Items with same flexibility maintain same relative size while
2548-
shrinking.</p>
2549-
2550-
<pre>
2551-
space-shortage = sum(flex-basis) - available-space
2552-
shrink-factor = space-shortage / sum(flex-basis * negative-flex))
2553-
main-size = flex-basis * (1 - shrink-factor * negative-flex))</pre>
2554-
2555-
<p> See <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=16856">
2556-
Bug 16856</a></p>
2557-
</div>
2534+
to the item's flexibility:
2535+
<dl>
2536+
<dt>If the flexibility is positive
2537+
2538+
<dd> Find the ratio of the item's <a
2539+
href="#positive-flexibility"><i>positive flex ratio</i></a> to the sum
2540+
of the <a href="#positive-flexibility"><i>positive flex ratios</i></a>
2541+
of all items on the line. Set the item's main size to its <a
2542+
href="#flex-basis"><i>flex basis</i></a> plus a fraction of the free
2543+
space proportional to the ratio.
2544+
2545+
<dt>If the flexibility is negative
2546+
2547+
<dd> For every item on the line, multiple its <a
2548+
href="#negative-flex-ratio"><i>negative flex ratio</i></a> by its <a
2549+
href="#flex-basis"><i>flex basis</i></a>, and note this as its <dfn
2550+
id=scaled-negative-flex-ratio>scaled negative flex ratio</dfn>. Find
2551+
the ratio of the item's <a href="#scaled-negative-flex-ratio"><i>scaled
2552+
negative flex ratio</i></a> to the sum of the <a
2553+
href="#scaled-negative-flex-ratio"><i>scaled negative flex
2554+
ratios</i></a> of all items on the line. Set the item's main size to
2555+
its <a href="#flex-basis"><i>flex basis</i></a> minus a fraction of the
2556+
free space proportional to the ratio.
2557+
</dl>
25582558

25592559
<li> <strong>Fix min/max violations.</strong> Clamp each item's main size
25602560
by its min and max main size properties. If the item's main size was made
@@ -3444,6 +3444,9 @@ <h2 class=no-num id=index>Index</h2>
34443444
class=css>row-reverse</code></a>’, <a href="#flex-flow-row-reverse"
34453445
title="''row-reverse''"><strong>6.1.</strong></a>
34463446

3447+
<li>scaled negative flex ratio, <a href="#scaled-negative-flex-ratio"
3448+
title="scaled negative flex ratio"><strong>9.7.</strong></a>
3449+
34473450
<li>single-line, <a href="#single-line"
34483451
title=single-line><strong>5.</strong></a>
34493452

css3-flexbox/Overview.src.html

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1813,30 +1813,31 @@ <h3 id='resolve-flexible-lengths'>
18131813
<strong>Distribute free space proportional to flexibility.</strong>
18141814
If the sign of the free space matches the sign of the flexibility,
18151815
distribute the free space to each flexible item's main size
1816-
in proportion to the item's flexibility.
1817-
1818-
<div class="issue">
1819-
<p>Growing and shrinking from flex basis should use different
1820-
formulas for space distribution.</p>
1821-
1822-
<p>Grow proportional to <em>
1823-
flexibility</em>. Items with equal flexibility grow by same
1824-
absolute amount.</p>
1825-
<pre>
1826-
free-space = available-space - sum(flex-basis)
1827-
main-size = flex-basis + free-space * positive-flex / sum(positive-flex)</pre>
1828-
1829-
<p>Shrink proportional to its <em>
1830-
flexibility and flex-basis.</em> Items with same flexibility maintain
1831-
same relative size while shrinking.</p>
1832-
<pre>
1833-
space-shortage = sum(flex-basis) - available-space
1834-
shrink-factor = space-shortage / sum(flex-basis * negative-flex))
1835-
main-size = flex-basis * (1 - shrink-factor * negative-flex))</pre>
1836-
<p>
1837-
See <a href="https://www.w3.org/Bugs/Public/show_bug.cgi?id=16856">
1838-
Bug 16856</a> </p>
1839-
</div>
1816+
in proportion to the item's flexibility:
1817+
1818+
<dl>
1819+
<dt>If the flexibility is positive</dt>
1820+
<dd>
1821+
Find the ratio of the item's <i>positive flex ratio</i>
1822+
to the sum of the <i>positive flex ratios</i> of all items on the line.
1823+
Set the item's main size
1824+
to its <i>flex basis</i>
1825+
plus a fraction of the free space
1826+
proportional to the ratio.
1827+
1828+
<dt>If the flexibility is negative</dt>
1829+
<dd>
1830+
For every item on the line,
1831+
multiple its <i>negative flex ratio</i>
1832+
by its <i>flex basis</i>,
1833+
and note this as its <dfn>scaled negative flex ratio</dfn>.
1834+
Find the ratio of the item's <i>scaled negative flex ratio</i>
1835+
to the sum of the <i>scaled negative flex ratios</i> of all items on the line.
1836+
Set the item's main size
1837+
to its <i>flex basis</i>
1838+
minus a fraction of the free space
1839+
proportional to the ratio.
1840+
</dl>
18401841

18411842
<li>
18421843
<strong>Fix min/max violations.</strong>

0 commit comments

Comments
 (0)