You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
to their <adata-link-type=dfnhref=#hypothetical-main-sizetitle="hypothetical main size">hypothetical main size</a>.
2324
2324
2325
-
<li>
2326
-
<strong>Check that you can distribute any space.</strong>
2327
-
If all the flex items on the line are either frozen
2328
-
or have a flex factor of zero,
2329
-
exit the algorithm.
2330
-
2331
2325
<li>
2332
2326
<strong>Calculate free space.</strong>
2333
2327
Sum the outer <adata-link-type=dfnhref=#flex-base-sizetitle="flex base sizes">flex base sizes</a> of all items on the line,
2334
2328
and subtract this from the flex container’s inner main size.
2335
2329
This is the free space.
2336
2330
2337
2331
<li>
2338
-
<strong>Distribute free space proportional to the flex factors.</strong>
2339
-
If the sign of the free space is positive and the algorithm is using the <adata-link-type=dfnhref=#flex-grow-factortitle="flex grow factor">flex grow factor</a>,
2340
-
or if the sign of the free space is negative and the algorithm is using the <adata-link-type=dfnhref=#flex-shrink-factortitle="flex shrink factor">flex shrink factor</a>,
2341
-
distribute the free space to each flexible item’s main size
2342
-
in proportion to the item’s flex factor:
2343
-
2344
-
<dl>
2345
-
<dt>If the free space is positive</dt>
2346
-
<dd>
2347
-
Find the ratio of the item’s <adata-link-type=dfnhref=#flex-grow-factortitle="flex grow factor">flex grow factor</a>
2348
-
to the sum of the <adata-link-type=dfnhref=#flex-grow-factortitle="flex grow factors">flex grow factors</a> of all items on the line.
2349
-
Set the item’s main size
2350
-
to its <adata-link-type=dfnhref=#flex-base-sizetitle="flex base size">flex base size</a>
2351
-
plus a fraction of the free space
2352
-
proportional to the ratio.
2353
-
2354
-
<dt>If the free space is negative</dt>
2355
-
<dd>
2356
-
For every item on the line,
2357
-
multiply its <adata-link-type=dfnhref=#flex-shrink-factortitle="flex shrink factor">flex shrink factor</a>
2358
-
by its outer <adata-link-type=dfnhref=#flex-base-sizetitle="flex base size">flex base size</a>,
2359
-
and note this as its <dfndata-dfn-type=dfndata-noexport="" id=scaled-flex-shrink-factor>scaled flex shrink factor<aclass=self-linkhref=#scaled-flex-shrink-factor></a></dfn>.
2360
-
Find the ratio of the item’s <adata-link-type=dfnhref=#scaled-flex-shrink-factortitle="scaled flex shrink factor">scaled flex shrink factor</a>
2361
-
to the sum of the <adata-link-type=dfnhref=#scaled-flex-shrink-factortitle="scaled flex shrink factors">scaled flex shrink factors</a> of all items on the line.
2362
-
Set the item’s main size
2363
-
to its <adata-link-type=dfnhref=#flex-base-sizetitle="flex base size">flex base size</a>
2364
-
minus a fraction of the absolute value of the free space
2365
-
proportional to the ratio.
2366
-
<spanclass=note>Note this may result in a negative inner main size;
2367
-
it will be corrected in the next step.</span>
2368
-
</dl>
2332
+
<strong>Calculate desired free space.</strong>
2333
+
If the free space is zero or positive,
2334
+
then for each <adata-link-type=dfnhref=#flex-itemtitle="flex item">flex item</a> on the line,
2335
+
its <var>originally desired free space</var>
2336
+
is the free space multiplied by the flex grow factor.
2337
+
2338
+
<p> Otherwise, if the free space is negative,
2339
+
then first sum the flex shrink factors of all the flex items on the line.
2340
+
If this number is greater than 1, set it to 1.
2341
+
Let this result be the <var>scaled flex factor sum</var>.
2342
+
For each flex item, multiply its flex shrink factor by its used based size.
2343
+
Then, renormalize each flex shrink factor so that their sum is the <var>scaled flex factor sum</var>.
2344
+
Then, multiple the flex shrink factor by the free space,
2345
+
and let the result be the <var>originally desired free space</var>.
2369
2346
2370
2347
<li>
2371
-
<strong>Fix min/max violations.</strong>
2372
-
Clamp each item’s main size by its min and max main size properties.
2373
-
If the item’s main size was made smaller by this, it’s a max violation.
2374
-
If the item’s main size was made larger by this, it’s a min violation.
2348
+
Loop:
2375
2349
2376
-
<li>
2377
-
The total violation is the sum of the adjustments from the previous step
reset all other items to their size upon entering this algorithm,
2390
-
and return to step 2 of this algorithm.
2391
-
2392
-
<dt>Negative
2393
-
<dd>
2394
-
Freeze all the items with max violations,
2395
-
reset all other items to their size upon entering this algorithm,
2396
-
and return to step 2 of this algorithm.
2397
-
</dl>
2350
+
<ol>
2351
+
<li>
2352
+
<strong>Check that you can distribute any space.</strong>
2353
+
If all the flex items on the line are either frozen
2354
+
or have a flex factor of zero,
2355
+
exit the algorithm.
2356
+
2357
+
<li>
2358
+
<strong>Reset desired free space.</strong>
2359
+
For each non-frozen flex item on the line,
2360
+
set its <var>desired free space</var>
2361
+
to its <var>originally desired free space</var>.
2362
+
2363
+
<li>
2364
+
<strong>Normalize desired free space if necessary.</strong>
2365
+
If the free space is positive,
2366
+
and the sum of the <var>desired free spaces</var> of all the flex items on the line
2367
+
is greater than the free space,
2368
+
normalize all the <var>desired free spaces</var> so that they sum exactly to the free space
2369
+
while maintaining their magnitudes relative to each other.
2370
+
2371
+
<p> Otherwise, if the free space is negative,
2372
+
and the sum of the <var>desired free spaces</var> of all the flex items on the line
2373
+
is less than the free space,
2374
+
normalize all the <var>desired free spaces</var> so that they sum exactly to the free space
2375
+
while maintaining their magnitudes relative to each other.
2376
+
2377
+
<li>
2378
+
<strong>Adjust main size.</strong>
2379
+
Add each item’s <var>desired free space</var> to its <adata-link-type=dfnhref=#hypothetical-main-sizetitle="hypothetical main size">hypothetical main size</a>.
2380
+
2381
+
<pclass=note> Note: This may result in a negative main size temporarily.
2382
+
2383
+
<li>
2384
+
<strong>Fix min/max violations.</strong>
2385
+
Clamp each item’s main size by its min and max main size properties.
2386
+
If the item’s main size was made smaller by this, it’s a max violation.
2387
+
If the item’s main size was made larger by this, it’s a min violation.
2388
+
2389
+
<li>
2390
+
The total violation is the sum of the adjustments from the previous step
0 commit comments