Skip to content

Commit c049dd1

Browse files
author
Jihye Hong
authored
Merge pull request #3732 from jihyerish/add-spatnav-action
[css-nav-1] Add spatial-navigation-action CSS Property
2 parents 8490cdd + e337fbe commit c049dd1

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

css-nav-1/Overview.bs

+76-1
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,7 @@ NOTE: The values of <var>alignWeight</var> and <var>orthogonalWeight</var> in th
12291229
<h2 id=declarative>
12301230
Controlling spatial navigation through declarative means</h2>
12311231

1232-
<h3 id=container>
1232+
<h3 id=css-property-spatialnavigationcontain>
12331233
Creating additional spatial navigation containers: the 'spatial-navigation-contain' property</h3>
12341234

12351235
<pre class='propdef'>
@@ -1347,6 +1347,81 @@ Note: the 'spatial-navigation-contain' property is <a>at-risk</a>.
13471347

13481348
</div>
13491349

1350+
<h3 id=css-property-spatialnavigationaction>
1351+
Defining the spatial navigation behavior : the 'spatial-navigation-action' property</h3>
1352+
1353+
<pre class='propdef'>
1354+
Name: spatial-navigation-action
1355+
Value: auto | focus | scroll
1356+
Initial: auto
1357+
Applies to: <a>scroll container</a>
1358+
Inherited: true
1359+
</pre>
1360+
1361+
When the user triggers spatial navigation in a given direction, the 'spatial-navigation-action' decides
1362+
the proper spatial navigation behavior.
1363+
1364+
<dl dfn-for=spatial-navigation-action dfn-type=value>
1365+
<dt><dfn>auto</dfn>
1366+
<dd>If the element is a <a>scroll container</a>,
1367+
then directional input moves the focus to the candidates in the optimal viewing region.
1368+
When there isn't any visible candidate, then the container scrolls.
1369+
1370+
Otherwise, the focus moves to the candidates in the viewport.
1371+
1372+
<dt><dfn>focus</dfn>
1373+
<dd>The directional input moves the focus to all candidates inside a scroll container. The container <a>cannot be scrolled manually</a>.
1374+
1375+
NOTE: If the 'focus' value is given to 'spatial-navigation-action',
1376+
<a event>navnotarget</a> event occurs when there isn’t any visible candidate in the given direction within the viewport of
1377+
the <a>spatial navigation container</a> even through the container can be scrolled more.
1378+
1379+
<dt><dfn>scroll</dfn>
1380+
<dd>If the element is a <a>scroll container</a>,
1381+
then directional input only works for manually scrolling the container.
1382+
1383+
Note: The 'scroll' value is <a>at-risk</a>.
1384+
</dl>
1385+
1386+
<div class=example>
1387+
In this example, a scrollable container is specified with <code highlight=css>spatial-navigation-action: focus</code>.
1388+
Inside the container, there is an element which is out of the view within a <a>scrollport</a>.
1389+
Pressing the right arrow key moves the focus directly to it without scrolling manually.
1390+
1391+
<figure>
1392+
<img alt="" src="images/spatnav-action.png" style="width: 500px;"/>
1393+
<figcaption>Moving focus from "Box 2" to "Box 3" without manually scrolling</figcaption>
1394+
</figure>
1395+
1396+
<pre><code highlight=markup>
1397+
&lt;div class = 'scroller'>
1398+
&lt;button class = 'item'>Box 1&lt;/button>
1399+
&lt;button class = 'item'>Box 2&lt;/button>
1400+
&lt;button class = 'item'>Box 3&lt;/button>
1401+
&lt;/div>
1402+
</code></pre>
1403+
<pre><code highlight=css>
1404+
.scroller {
1405+
display: grid;
1406+
grid-template-columns: repeat(1, 1fr);
1407+
height: 300px;
1408+
width: 200px;
1409+
overflow-y: scroll;
1410+
spatial-navigation-action: focus;
1411+
}
1412+
.item {
1413+
height: 100px;
1414+
width: 100px;
1415+
margin: 50px auto;
1416+
background-color: blue;
1417+
}
1418+
:focus {
1419+
background-color: red;
1420+
}
1421+
</code></pre>
1422+
1423+
</div>
1424+
13501425
<h2 class=no-num id=scrolling>Appendix A. Scroll extensions</h2>
13511426

13521427
This section proposes a few extensions to CSS

css-nav-1/images/spatnav-action.png

22.9 KB
Loading

0 commit comments

Comments
 (0)