Skip to content

Commit

Permalink
[motion-1] Clarify meaning of contain
Browse files Browse the repository at this point in the history
'smallest clipped area' gave no guidance when the path and the box
had zero area in common regarless of the value of offset-distance.

For example, this can occur when the path size is 0, or when
offset-anchor is substantially outside the box.

We now define the meaning of 'contain' by specifying that the path
size is minimally increased so that the box can be contained.

resolves w3c#22
  • Loading branch information
ericwilligers committed Jun 28, 2017
1 parent 1e8825e commit 0dfb6bc
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 3 deletions.
35 changes: 32 additions & 3 deletions motion-1/Overview.bs
Expand Up @@ -182,9 +182,9 @@ Values have the following meanings:
<dl>
<dt><dfn>contain</dfn></dt>
<dd>
Makes the box don't have clipped area by altering the length of the <a>offset path</a> when the part of the box on the <a>offset path</a> is outside the edge of the containing block.
If the box is larger than the containing block, the box would be positioned where it has the smallest clipped area by modifying the <a>offset path</a>’s length with reducing the least amount.
The used value of 'offset-distance' is clamped so that the box is entirely contained within the path.

If no 'offset-distance' would lead to the box being enclosed by the path, the path size is minimally increased so that such an 'offset-distance' exists.
</dd>
</dl>

Expand Down Expand Up @@ -258,6 +258,35 @@ Values have the following meanings:
<img alt="An image of boxes positioned with contain" src="images/offset_distance_with_contain.png" style="width: 200px;"/>
<figcaption>'offset-path' with 'contain'</figcaption>
</div>
In the third example, the path size is increased so that the box can be contained. The <a>used offset distance</a> is negative.
<pre class="lang-html">
&lt;style>
body {
transform-style: preserve-3d;
width: 250px;
height: 250px;
}
.box {
width: 60%;
height: 10%;

offset-position: 20% 20%;
offset-distance: 0%;
offset-anchor: 200% -300%;
}
#blueBox {
background-color: blue;
offset-path: ray(-90deg closest-side contain);
}
&lt;/style>
&lt;body>
&lt;div class="box" id="blueBox">&lt;/div>
&lt;/body>
</pre>
<div class=figure>
<img alt="An image of an increased path size" src="images/increase-size.svg" style="width: 400px; height: 335;"/>
<figcaption>'offset-path' with path size increased</figcaption>
</div>
</div>
</dd>

Expand Down Expand Up @@ -431,7 +460,7 @@ To determine the <dfn>used offset distance</dfn> for a given <a>offset path</a>
: If <a>offset path</a> is an unbounded ray:
:: Let <a>used offset distance</a> be equal to <a>offset distance</a>.
: Otherwise if <a>offset path</a> is an <<angle>> path with contain:
:: Let <a>used offset distance</a> be equal to <a>offset distance</a>, clamped in magnitude by the total length of the path.
:: Let <a>used offset distance</a> be equal to <a>offset distance</a>, clamped so that the box lies entirely within the path.
: If <a>offset path</a> is any other unclosed interval:
:: Let <a>used offset distance</a> be equal to <a>offset distance</a> clamped by 0 and the total length of the path.
: Otherwise <a>offset path</a> is a closed loop:
Expand Down
28 changes: 28 additions & 0 deletions motion-1/images/increase-size.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0dfb6bc

Please sign in to comment.