Skip to content

Commit ffda3a6

Browse files
committed
[css-grid-3][masonry] Add tie threshold property for masonry placement w3c#9328
1 parent 6c59f12 commit ffda3a6

File tree

1 file changed

+51
-12
lines changed

1 file changed

+51
-12
lines changed

css-grid-3/Overview.bs

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,48 @@ Masonry Placement</h3>
719719
(and their 'grid-column' shorthand).
720720
</section>
721721

722+
<h3 id="masonry-slack">
723+
Placement Precision: the 'masonry-slack' property</h3>
724+
725+
<pre class=propdef>
726+
Name: masonry-slack
727+
Value: <<length-percentage>>
728+
Initial: 1em
729+
Percentages: relative to the [=grid-axis=] [=content box=] size of the [=masonry container=]
730+
Inherited: no
731+
Applies to: [=masonry containers=]
732+
Computed value: a computed length
733+
Animation type: discrete
734+
</pre>
735+
736+
[=Masonry containers=] are filled
737+
by placing each [=masonry item=]
738+
in whichever [=masonry track=] is currently the least filled.
739+
When multiple tracks are tied for least-filled,
740+
placing the items in order looks good.
741+
But if tracks are only <em>very slightly</em> different heights,
742+
it can look strange to have them not fill in order,
743+
as the height differences aren't perceived as <em>meaningfully</em> different.
744+
745+
The 'masonry-slack' property specifies what the threshold is
746+
for considering tracks to be “the same height”,
747+
causing them to fill in order.
748+
749+
<dl dfn-type=value dfn-for=masonry-slack>
750+
: <dfn><<length>></dfn>
751+
:: Specifies the <dfn dfn for=masonry>tie threshold</dfn>
752+
for the [=masonry container=].
753+
Placement positions are considered to be equally good (“tied”)
754+
if they are within the specified distance
755+
from the shortest position.
756+
757+
Note: The initial value is a “small” distance (''1em'')
758+
that is probably appropriate to represent “close enough”.
759+
</dl>
760+
761+
Issue: Is ''1em'' the right default?
762+
763+
722764
<h3 id="masonry-layout-algorithm">
723765
Masonry Layout and Placement Algorithm</h3>
724766

@@ -735,24 +777,21 @@ Masonry Layout and Placement Algorithm</h3>
735777

736778
ISSUE: Should this also update the placement cursor?
737779

738-
Otherwise, resolve its [=grid axis=] placement using these substeps:
780+
Otherwise, resolve its [=grid axis=] placement using these substeps:
739781

740782
<ol>
741-
<li>Starting at the first [=grid axis=] line in the [=implicit grid=].
742-
<li>Find the largest [=running position=] of the [=grid axis=] tracks
783+
<li>Starting at the first [=grid axis=] line in the [=implicit grid=],
784+
find the largest [=running position=] of the [=grid axis=] tracks
743785
that the item would span if it were placed at this line,
744786
and call this position <var>max_pos</var>.
745787
<li>Increment the line number and repeat step 2
746788
until the item would no longer fit inside the grid.
747-
<li>Pick the line that resulted in the smallest <var>max_pos</var>
748-
as the item's definite placement in the [=grid axis=].
749-
If multiple lines qualify,
750-
choose the first one greater than or equal to the [=auto-placement cursor=],
751-
or if there are none such,
752-
choose the first one.
753-
<li>Update the [=auto-placement cursor=] to point to item's last line;
754-
however if this is the last line in the grid,
755-
switch it to the first line.
789+
<li>Let |possible lines| be the line that resulted in the smallest <var>max_pos</var>,
790+
and all lines that result in a <var>max_pos</var> within the [=tie threshold=] of this <var>max_pos</var>.
791+
<li>Choose the first line in |possible lines| greater than or equal to the [=auto-placement cursor=]
792+
as the item's definite placement in the [=grid axis=];
793+
or if there are none such, choose the first one.
794+
<li>Update the [=auto-placement cursor=] to point to item's last line.
756795
</ol>
757796

758797
<li>

0 commit comments

Comments
 (0)