Skip to content

Commit a47da55

Browse files
authored
Merge pull request w3c#4 from WICG/master
Merge from WICG master
2 parents 8dfd1e6 + 637b367 commit a47da55

14 files changed

+474
-259
lines changed

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This is a repository for making the Web excellently embrace the spatial navigati
1010
* Give feedback on [issues](https://github.com/WICG/spatial-navigation/issues) or via [email](mailto://lgewst@gmail.com)
1111

1212
## Overview
13-
**Spatial navigation (aka Spatnav)** is the ability to navigate between focusable elements based on their position within a structured document. Spatial navigation is often called 'directional navigation' which enables four(4) directional navigation. Users are usually familiar with the 2-way navigation using tab key for the forward direction and shift+tab key for the backward direction, but not familiar with the 4-way navigation using arrow keys.
13+
**Spatial navigation** is the ability to navigate between focusable elements based on their position within a structured document. Spatial navigation is often called 'directional navigation' which enables four(4) directional navigation. Users are usually familiar with the 2-way navigation using tab key for the forward direction and shift+tab key for the backward direction, but not familiar with the 4-way navigation using arrow keys.
1414

1515
Regarding TV remote control, game console pad, IVI jog dial with 4-way keys, and Web accessibility, the spatial navigation has been a rising important input mechanism in several industries. If the Web can embrace the spatial navigation and efficiently support the functionalities in Web engines and W3C APIs, it will be more promising technology for existing products as mentioned above and various upcoming smart devices.
1616

@@ -20,33 +20,33 @@ Prior to the mission explanation, we need to understand how the arrow keys work
2020
In spatial navigation mode, the default behavior of arrow keys is changed from scrolling behavior to focus moving so that users can use the arrow keys to navigate between focusable elements based on their position. To support the functionalities of the spatial navigation, we should consider the following three steps:
2121
1. A heuristic algorithm for the spatial navigation supported in Web engines
2222
2. Overriding methods on top of the heuristic algorithm (DOM method/attribute/event)
23-
3. The relevant API for efficiently supporting the spatial navigation (spatnav mode, container, etc.)
23+
3. The relevant API for efficiently supporting the spatial navigation (Setting the spatial navigation container, etc.)
2424

2525
See the [explainer](explainer.md) for the details of W3C standardization for #1, #2 and #3 above.
2626

2727
See the [implStatus](implStatus.md) for the details of the implementation in Web engines for #2 above.
2828

2929
## FAQ
30-
**Q. I’m not sure how the Spatnav (directional) navigation works.**
31-
- You can see the video that shows the Spatnav operations in the YouTube page ([link](https://www.youtube.com/watch?v=TzDtcX9urUg)).
32-
- You can see the brief description for the Spatnav in Wikipedia ([link](https://en.wikipedia.org/wiki/Spatial_navigation)).
33-
- In several references below, you can get the help to understand the Spatnav operations well.
30+
**Q. I’m not sure how the spatial navigation works.**
31+
- You can see the video that shows the spatial navigation operations in the YouTube page ([link](https://www.youtube.com/watch?v=TzDtcX9urUg)).
32+
- You can see the brief description for the spatial navigation in Wikipedia ([link](https://en.wikipedia.org/wiki/Spatial_navigation)).
33+
- In several references below, you can get the help to understand the spatial navigation operations well.
3434

3535
**Q. Isn’t it enough just using the relevant Web frameworks?**
36-
- Several Web frameworks and extensions for the Spatnav have been provided so far due to no support from web engines. For examples, [js-spatial-navigation](https://github.com/luke-chang/js-spatial-navigation) made by Mozilla seems one of the frameworks and its quality would be good to support the features of Spatnav. [Spotlight library](https://github.com/enyojs/spotlight) implemented by LGE is also an instance of the frameworks for the Spatnav, even though it was deprecated now. However, the support of Spatnav from Web frameworks has some limits as follows:
36+
- Several Web frameworks and extensions for the spatial navigation have been provided so far due to no support from web engines. For examples, [js-spatial-navigation](https://github.com/luke-chang/js-spatial-navigation) made by Mozilla seems one of the frameworks and its quality would be good to support the features of the spatial navigation. [Spotlight library](https://github.com/enyojs/spotlight) implemented by LGE is also an instance of the frameworks for the spatial navigation, even though it was deprecated now. However, the support of spatial navigation from Web frameworks has some limits as follows:
3737
- Difficult to align native scroll behavior when moving the focus to an element out of view
3838
- Difficult to align native focus method for a11y support
3939
- Performance degradation due to the expensive cost of DOM Access
4040
- Inconsistency of user experience (various kinds of frameworks)
4141
- Impossible to control isolated frames like iframe and shadow DOM
4242

43-
**Q. The Spatnav seems not the general feature esp. in mobile with no physical key-based interface.**
44-
- Honestly, the mobile has been a first citizen of Spatnav about ten years old. Before touch-based interface, the majority of interface for mobile was the key-based interface. We're familiar with kind of mobile phone named a feature phone, and it has been supported in several developing countries such as South America, Africa even until now.
43+
**Q. The spatial navigation seems not the general feature esp. in mobile with no physical key-based interface.**
44+
- Honestly, the mobile has been a first citizen of the spatial navigation about ten years old. Before touch-based interface, the majority of interface for mobile was the key-based interface. We're familiar with kind of mobile phone named a feature phone, and it has been supported in several developing countries such as South America, Africa even until now.
4545

4646
- In the future, the input mechanism for smart devices will change to something like voice command, hand gesture, and gaze direction, but the key-based interface will never disappear, even though it'll be used as a secondary method. The key-based interface used to be evaluated as one of the most intuitive ways with a strong sense feedback of finger after pushing a key, while we couldn't imagine a touch-based keyboard without any physical keys.
4747

4848
**Q. Put any question on [issues](https://github.com/WICG/spatial-navigation/issues) of this repository :D**
49-
- Everything for Spatnav is welcome!
49+
- Everything for the spatial navigation is welcome!
5050

5151
## Reference
5252
- JavaScript Spatial Navigation (Mozilla)

demo/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,22 +134,22 @@ <h3 id="input-elements">* &lt;input&gt; elements</h3>
134134

135135
<h3 id="spatnav-container">* Spatial navigation container</h3>
136136
<p class="iframe-description"></p>
137-
<iframe src="sample/api_spatnav_contain.html"></iframe>
137+
<iframe src="sample/api_spatial_navigation_contain.html"></iframe>
138138
</div>
139139

140140
<div class="card-view">
141141
<h2 tabIndex="0" id="api">3. API</h2>
142-
<h3 id="getSpatnavContainer">* getSpatnavContainer() <a href="https://wicg.github.io/spatial-navigation/#dom-element-getspatnavcontainer" target="_blank"><img src="link.png" width="20px"/></a></h3>
142+
<h3 id="getSpatnavContainer">* getSpatialNavigationContainer() <a href="https://wicg.github.io/spatial-navigation/#dom-element-getspatialnavigationcontainer" target="_blank"><img src="link.png" width="20px"/></a></h3>
143143
<p class="iframe-description"></p>
144-
<iframe src="sample/api_getSpatnavContainer.html"></iframe>
144+
<iframe src="sample/api_getSpatialNavigationContainer.html"></iframe>
145145

146146
<h3 id="focusableAreas">* focusableAreas(optional focusableAreasOptions) <a href="https://wicg.github.io/spatial-navigation/#dom-element-focusableareas" target="_blank"><img src="link.png" width="20px"/></a></h3>
147147
<p class="iframe-description"></p>
148148
<iframe src="sample/api_focusableAreas.html"></iframe>
149149

150-
<h3 id="spatNavSearch">* spatNavSearch(arg) <a href="https://wicg.github.io/spatial-navigation/#dom-element-spatnavsearch" target="_blank"><img src="link.png" width="20px"/></a></h3>
150+
<h3 id="spatNavSearch">* spatialNavigationSearch() <a href="https://wicg.github.io/spatial-navigation/#dom-element-spatialnavigationsearch" target="_blank"><img src="link.png" width="20px"/></a></h3>
151151
<p class="iframe-description"></p>
152-
<iframe class="api-sample" src="sample/api_spatNavSearch.html"></iframe>
152+
<iframe class="api-sample" src="sample/api_spatialNavigationSearch.html"></iframe>
153153

154154
<h3 id="navigate">* navigate(dir) <a href="https://wicg.github.io/spatial-navigation/#dom-window-navigate" target="_blank"><img src="link.png" width="20px"/></a></h3>
155155
<p class="iframe-description"></p>

demo/sample/api_getSpatnavContainer.html renamed to demo/sample/api_getSpatialNavigationContainer.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<meta name="application-name" content="API : getSpatnavContainer()">
6+
<meta name="application-name" content="API : getSpatialNavigationContainer()">
77
<meta name="author" content="jeonghee Ahn">
8-
<meta name="description" content="element.getSpatnavContainer() returns the nearest ancestor node which is the spatial navigation container (a.k.a. spatnav container).
9-
You can check the result of element.getSpatnavContainer() via <b>'background-color' and 'red outline' whenever focus is changed.</b>">
8+
<meta name="description" content="element.getSpatialNavigationContainer() returns the nearest ancestor node which is the spatial navigation container.
9+
You can check the result of element.getSpatialNavigationContainer() via <b>'background-color' and 'red outline' whenever focus is changed.</b>">
1010
<link rel="stylesheet" href="spatnav-style.css">
1111
<script src="spatnav-utils.js"></script>
1212
<script src="../../polyfill/spatnav-heuristic.js"></script>
@@ -26,7 +26,7 @@
2626
previousContainer.style.background = previousBackground;
2727
previousContainer.style.outline = '';
2828
}
29-
const spatnavContainer = e.target.getSpatnavContainer();
29+
const spatnavContainer = e.target.getSpatialNavigationContainer();
3030
previousBackground = spatnavContainer.style.background;
3131
spatnavContainer.style.background = '#F0808099';
3232
spatnavContainer.style.outline = '5px red solid';
@@ -65,10 +65,10 @@ <h4>
6565
<button class="box" style="top:-120px; left:650px;"></button>
6666
</div>
6767
<pre class="code-area">
68-
<code> // Node getSpatnavContainer()
68+
<code> // Node getSpatialNavigationContainer()
6969
console.log(focusables);
7070
focusable.addEventListener('focus', function(e) {
71-
let spatnavContainer = e.target.getSpatnavContainer();
71+
let spatnavContainer = e.target.getSpatialNavigationContainer();
7272
spatnavContainer.style.background = '#F0808099';
7373
spatnavContainer.style.outline = '5px red solid';
7474
console.log(spatnavContainer);

demo/sample/api_navigate.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
console.log('========init=======');
2020
const WASD_KEY_CODE = {65: 'left', 87: 'up', 68: 'right', 83: 'down'}
2121

22-
// Turn on spatnav heuristic
22+
// Turn on the spatial navigation heuristic
2323
const container = document.getElementsByClassName('container c1')[0];
2424
container.addEventListener('keydown', function(e) {
2525
const dir = WASD_KEY_CODE[e.keyCode];

demo/sample/api_spatNavSearch.html renamed to demo/sample/api_spatialNavigationSearch.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
<head>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<meta name="application-name" content="API :spatNavSearch()">
6+
<meta name="application-name" content="API :spatialNavigationSearch()">
77
<meta name="author" content="jeonghee Ahn">
8-
<meta name="description" content="element.spatNavSearch(SpatNavSearchOptions) returns the best candidate which will gain the focus.
9-
You can check the result of element.spatNavSearch() as <b>'border-color' whenever the container gains the focus.</b>">
8+
<meta name="description" content="element.spatialNavigationSearch(SpatialNavigationSearchOptions) returns the best candidate which will gain the focus.
9+
You can check the result of element.spatialNavigationSearch() as <b>'border-color' whenever the container gains the focus.</b>">
1010
<link rel="stylesheet" href="spatnav-style.css">
1111
<script src="spatnav-utils.js"></script>
1212
<script src="../../polyfill/spatnav-heuristic.js"></script>
@@ -24,14 +24,14 @@
2424
const focusables = document.body.focusableAreas({'mode': 'all'});
2525

2626
for(focusable of focusables) {
27-
focusable.addEventListener('focus', callSpatNavSearch);
27+
focusable.addEventListener('focus', callSpatialNavigationSearch);
2828
}
2929
redBoxes = [...document.getElementsByClassName('b2')];
3030
redContainer = document.getElementsByClassName('container c1')[0];
3131
onChangeSelect();
3232
};
3333

34-
function callSpatNavSearch(e) {
34+
function callSpatialNavigationSearch(e) {
3535
const selectedOption = document.getElementById('option').value;
3636
const currentElement = e.target;
3737
if(previousTarget) {
@@ -42,16 +42,16 @@
4242
}
4343
}
4444

45-
let SpatNavSearchOptions;
45+
let SpatialNavigationSearchOptions;
4646

4747
for(let dir of DIRECTION) {
4848
let nextTarget;
4949
if (selectedOption === 'dir') {
50-
nextTarget = currentElement.spatNavSearch(dir);
50+
nextTarget = currentElement.spatialNavigationSearch(dir);
5151
} else if (selectedOption === 'candidates') {
52-
nextTarget = currentElement.spatNavSearch(dir, redBoxes);
52+
nextTarget = currentElement.spatialNavigationSearch(dir, redBoxes);
5353
} else if (selectedOption === 'container') {
54-
nextTarget = currentElement.spatNavSearch(dir, redBoxes, redContainer);
54+
nextTarget = currentElement.spatialNavigationSearch(dir, redBoxes, redContainer);
5555
}
5656

5757
if(nextTarget && nextTarget.nodeName === 'BUTTON') {
@@ -75,17 +75,17 @@
7575
}
7676

7777
let codeElement = document.getElementById('code');
78-
codeElement.innerText =` // Node spatNavSearch(SpatNavSearchOptions arg);
79-
nextTarget = currentElement.spatNavSearch(${selectedOptionString.left});
78+
codeElement.innerText =` // Node spatialNavigationSearch(SpatialNavigationSearchOptions arg);
79+
nextTarget = currentElement.spatialNavigationSearch(${selectedOptionString.left});
8080
if (nextTarget)
8181
nextTarget.style.innerHTML = '◀';
82-
nextTarget = currentElement.spatNavSearch(${selectedOptionString.right});
82+
nextTarget = currentElement.spatialNavigationSearch(${selectedOptionString.right});
8383
if (nextTarget.right)
8484
nextTarget.style.innerHTML = '▶';
85-
nextTarget = currentElement.spatNavSearch(${selectedOptionString.up});
85+
nextTarget = currentElement.spatialNavigationSearch(${selectedOptionString.up});
8686
if (nextTarget.up)
8787
nextTarget.style.innerHTML = '▲';
88-
nextTarget = currentElement.spatNavSearch(${selectedOptionString.down});
88+
nextTarget = currentElement.spatialNavigationSearch(${selectedOptionString.down});
8989
if (nextTarget.down)
9090
nextTarget.style.innerHTML = '▼';`
9191

demo/sample/api_spatnav_contain.html renamed to demo/sample/api_spatial_navigation_contain.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<meta name="application-name" content="Spatial Navigation Container">
77
<meta name="author" content="Jihye Hong">
8-
<meta name="description" content="By default, <b>spatial navigation container (a.k.a. spatnav container)</b> are established by the viewport of a browsing context and scroll containers. Also, an element becomes spatnav container if it is specified with 'spatial-navigation-contain' CSS Property.">
8+
<meta name="description" content="By default, <b>spatial navigation container</b> are established by the viewport of a browsing context and scroll containers.
9+
Also, an element becomes a spatial navigation container if it is specified with 'spatial-navigation-contain' CSS Property.">
910
<link rel="stylesheet" href="spatnav-style.css">
1011
<script src="spatnav-utils.js"></script>
1112
<script src="../../polyfill/spatnav-heuristic.js"></script>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta name="application-name" content="inert attribute">
7+
<meta name="author" content="Jihye Hong">
8+
<meta name="description" content="Element which has the value of inert is true is considered as a non-focusable element.
9+
It is shown in the page, but it's impossible to interact with it.">
10+
<link rel="stylesheet" href="spatnav-style.css">
11+
<script src="spatnav-utils.js"></script>
12+
<script src="../../polyfill/spatnav-heuristic.js"></script>
13+
</head>
14+
<body>
15+
<div class="container" style="width:600px; height:500px;">
16+
<input type="text" value="You can edit this element"><br>
17+
<input id="option" type="checkbox">Check this to edit the forms below:
18+
19+
<br><br>
20+
<div id="inert_elm" inert style="border: 1px solid gray; padding: 10px; opacity: 0.5;">
21+
<textarea>type something</textarea><br>
22+
<input type="radio" name="radio1" checked> radio1
23+
<input type="radio" name="radio1" > radio2
24+
<input type="radio" name="radio1" > radio3
25+
<br><br>
26+
<select>
27+
<option>Hi</option>
28+
<option>Ho</option>
29+
</select>
30+
</div>
31+
</div>
32+
</body>
33+
<script type="text/javascript">
34+
const el = document.querySelector('#inert_elm');
35+
let check_box = document.getElementById('option');
36+
37+
if(check_box.checked)
38+
applyInert(el, check_box.checked);
39+
40+
check_box.onchange = function() {
41+
applyInert(el, check_box.checked);
42+
}
43+
44+
function applyInert(elm, boolean) {
45+
if (boolean) {
46+
elm.inert = false;
47+
elm.style.opacity = '1';
48+
} else {
49+
elm.inert = true;
50+
elm.style.opacity = '0.5';
51+
}
52+
}
53+
</script>
54+
</html>

demo/sample/heuristic_input_elements.html

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,40 @@
5757
<div><p class="label">range</p><input type="range"></div>
5858
<div><p class="label">time</p><input type="time"></div>
5959
<div><p class="label">week</p><input type="week"></div>
60+
<div><p class="label">datalist</p>
61+
<form>
62+
<input list="browsers" name="browser">
63+
<datalist id="browsers">
64+
<option value="Edge">
65+
<option value="Firefox">
66+
<option value="Chrome">
67+
<option value="Opera">
68+
<option value="Safari">
69+
</datalist>
70+
</form>
71+
</div>
72+
<div><p class="label">select</p>
73+
<select>
74+
<option value="edge">Edge</option>
75+
<option value="firefox">Firefox</option>
76+
<option value="chrome">Chrome</option>
77+
<option value="opera">Opera</option>
78+
<option value="safari">Safari</option>
79+
</select>
80+
</div>
81+
<div><p class="label">optgroup</p>
82+
<select>
83+
<optgroup label="Swedish Cars">
84+
<option value="volvo">Volvo</option>
85+
<option value="saab">Saab</option>
86+
</optgroup>
87+
<optgroup label="German Cars">
88+
<option value="mercedes">Mercedes</option>
89+
<option value="audi">Audi</option>
90+
</optgroup>
91+
</select>
92+
</div>
93+
<!--end of the list -!>
6094
</div>
6195
</body>
6296
</html>

0 commit comments

Comments
 (0)