Skip to content

Commit

Permalink
Merge pull request w3c#116 from jihyerish/remove-spatnav-abbreviation
Browse files Browse the repository at this point in the history
Remove "spatnav" abbreviation
  • Loading branch information
Jihye Hong authored Oct 15, 2018
2 parents 7aa9337 + 57fb18a commit 26e9a69
Show file tree
Hide file tree
Showing 10 changed files with 192 additions and 194 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This is a repository for making the Web excellently embrace the spatial navigati
* Give feedback on [issues](https://github.com/WICG/spatial-navigation/issues) or via [email](mailto://lgewst@gmail.com)

## Overview
**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.
**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.

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.

Expand All @@ -20,33 +20,33 @@ Prior to the mission explanation, we need to understand how the arrow keys work
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:
1. A heuristic algorithm for the spatial navigation supported in Web engines
2. Overriding methods on top of the heuristic algorithm (DOM method/attribute/event)
3. The relevant API for efficiently supporting the spatial navigation (spatnav mode, container, etc.)
3. The relevant API for efficiently supporting the spatial navigation (Setting the spatial navigation container, etc.)

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

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

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

**Q. Isn’t it enough just using the relevant Web frameworks?**
- 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:
- 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:
- Difficult to align native scroll behavior when moving the focus to an element out of view
- Difficult to align native focus method for a11y support
- Performance degradation due to the expensive cost of DOM Access
- Inconsistency of user experience (various kinds of frameworks)
- Impossible to control isolated frames like iframe and shadow DOM

**Q. The Spatnav seems not the general feature esp. in mobile with no physical key-based interface.**
- 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.
**Q. The spatial navigation seems not the general feature esp. in mobile with no physical key-based interface.**
- 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.

- 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.

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

## Reference
- JavaScript Spatial Navigation (Mozilla)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="application-name" content="API : getSpatnavContainer()">
<meta name="application-name" content="API : getSpatialNavigationContainer()">
<meta name="author" content="jeonghee Ahn">
<meta name="description" content="element.getSpatnavContainer() returns the nearest ancestor node which is the spatial navigation container (a.k.a. spatnav container).
You can check the result of element.getSpatnavContainer() via <b>'background-color' and 'red outline' whenever focus is changed.</b>">
<meta name="description" content="element.getSpatialNavigationContainer() returns the nearest ancestor node which is the spatial navigation container.
You can check the result of element.getSpatialNavigationContainer() via <b>'background-color' and 'red outline' whenever focus is changed.</b>">
<link rel="stylesheet" href="spatnav-style.css">
<script src="spatnav-utils.js"></script>
<script src="../../polyfill/spatnav-heuristic.js"></script>
Expand All @@ -26,7 +26,7 @@
previousContainer.style.background = previousBackground;
previousContainer.style.outline = '';
}
const spatnavContainer = e.target.getSpatnavContainer();
const spatnavContainer = e.target.getSpatialNavigationContainer();
previousBackground = spatnavContainer.style.background;
spatnavContainer.style.background = '#F0808099';
spatnavContainer.style.outline = '5px red solid';
Expand Down Expand Up @@ -65,10 +65,10 @@ <h4>
<button class="box" style="top:-120px; left:650px;"></button>
</div>
<pre class="code-area">
<code> // Node getSpatnavContainer()
<code> // Node getSpatialNavigationContainer()
console.log(focusables);
focusable.addEventListener('focus', function(e) {
let spatnavContainer = e.target.getSpatnavContainer();
let spatnavContainer = e.target.getSpatialNavigationContainer();
spatnavContainer.style.background = '#F0808099';
spatnavContainer.style.outline = '5px red solid';
console.log(spatnavContainer);
Expand Down
2 changes: 1 addition & 1 deletion demo/sample/api_navigate.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
console.log('========init=======');
const WASD_KEY_CODE = {65: 'left', 87: 'up', 68: 'right', 83: 'down'}

// Turn on spatnav heuristic
// Turn on the spatial navigation heuristic
const container = document.getElementsByClassName('container c1')[0];
container.addEventListener('keydown', function(e) {
const dir = WASD_KEY_CODE[e.keyCode];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="application-name" content="API :spatNavSearch()">
<meta name="application-name" content="API :spatialNavigationSearch()">
<meta name="author" content="jeonghee Ahn">
<meta name="description" content="element.spatNavSearch(SpatNavSearchOptions) returns the best candidate which will gain the focus.
You can check the result of element.spatNavSearch() as <b>'border-color' whenever the container gains the focus.</b>">
<meta name="description" content="element.spatialNavigationSearch(SpatialNavigationSearchOptions) returns the best candidate which will gain the focus.
You can check the result of element.spatialNavigationSearch() as <b>'border-color' whenever the container gains the focus.</b>">
<link rel="stylesheet" href="spatnav-style.css">
<script src="spatnav-utils.js"></script>
<script src="../../polyfill/spatnav-heuristic.js"></script>
Expand All @@ -24,14 +24,14 @@
const focusables = document.body.focusableAreas({'mode': 'all'});

for(focusable of focusables) {
focusable.addEventListener('focus', callSpatNavSearch);
focusable.addEventListener('focus', callSpatialNavigationSearch);
}
redBoxes = [...document.getElementsByClassName('b2')];
redContainer = document.getElementsByClassName('container c1')[0];
onChangeSelect();
};

function callSpatNavSearch(e) {
function callSpatialNavigationSearch(e) {
const selectedOption = document.getElementById('option').value;
const currentElement = e.target;
if(previousTarget) {
Expand All @@ -42,16 +42,16 @@
}
}

let SpatNavSearchOptions;
let SpatialNavigationSearchOptions;

for(let dir of DIRECTION) {
let nextTarget;
if (selectedOption === 'dir') {
nextTarget = currentElement.spatNavSearch(dir);
nextTarget = currentElement.spatialNavigationSearch(dir);
} else if (selectedOption === 'candidates') {
nextTarget = currentElement.spatNavSearch(dir, redBoxes);
nextTarget = currentElement.spatialNavigationSearch(dir, redBoxes);
} else if (selectedOption === 'container') {
nextTarget = currentElement.spatNavSearch(dir, redBoxes, redContainer);
nextTarget = currentElement.spatialNavigationSearch(dir, redBoxes, redContainer);
}

if(nextTarget && nextTarget.nodeName === 'BUTTON') {
Expand All @@ -75,17 +75,17 @@
}

let codeElement = document.getElementById('code');
codeElement.innerText =` // Node spatNavSearch(SpatNavSearchOptions arg);
nextTarget = currentElement.spatNavSearch(${selectedOptionString.left});
codeElement.innerText =` // Node spatialNavigationSearch(SpatialNavigationSearchOptions arg);
nextTarget = currentElement.spatialNavigationSearch(${selectedOptionString.left});
if (nextTarget)
nextTarget.style.innerHTML = '◀';
nextTarget = currentElement.spatNavSearch(${selectedOptionString.right});
nextTarget = currentElement.spatialNavigationSearch(${selectedOptionString.right});
if (nextTarget.right)
nextTarget.style.innerHTML = '▶';
nextTarget = currentElement.spatNavSearch(${selectedOptionString.up});
nextTarget = currentElement.spatialNavigationSearch(${selectedOptionString.up});
if (nextTarget.up)
nextTarget.style.innerHTML = '▲';
nextTarget = currentElement.spatNavSearch(${selectedOptionString.down});
nextTarget = currentElement.spatialNavigationSearch(${selectedOptionString.down});
if (nextTarget.down)
nextTarget.style.innerHTML = '▼';`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="application-name" content="Spatial Navigation Container">
<meta name="author" content="Jihye Hong">
<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.">
<meta name="description" content="By default, <b>spatial navigation container</b> are established by the viewport of a browsing context and scroll containers.
Also, an element becomes a spatial navigation container if it is specified with 'spatial-navigation-contain' CSS Property.">
<link rel="stylesheet" href="spatnav-style.css">
<script src="spatnav-utils.js"></script>
<script src="../../polyfill/spatnav-heuristic.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion demo/sample/heuristic_text_type_elements.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h3>Details</h3>

<h3>Overview</h3>

Spatial navigation (aka Spatnav) is the ability to navigate between focusable elements based on their position
The 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,
Expand Down
19 changes: 9 additions & 10 deletions explainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ since no other input mechanism is available on a typical TV remote control.
Others, have enabled different key combinations to control spatial navigation,
such as pressing the <code class="key">Shift</code> key together with arrow keys.

This ability to move around the page directionally is called <strong>spatial navigation</strong>
(or <strong>spatnav</strong> for short).
This ability to move around the page directionally is called <strong>spatial navigation</strong>.

An [experimental Polyfill](./polyfill/) is available.

Expand Down Expand Up @@ -110,7 +109,7 @@ and especially on devices such as TVs which also lack a <code>Tab</code> key to
<a herf="https://html.spec.whatwg.org/multipage/interaction.html#sequential-focus-navigation">sequential focus navigation</a>,
User Agents should make spatial navigation active.

We deliberately do not define which keys or key combination are meant to trigger spatnav,
We deliberately do not define which keys or key combination are meant to trigger the spatial navigation,
nor whether it is on by default or not.
These are choices that are best left to the user and the User Agent.
This is discussed in greater detail in <a href="https://github.com/WICG/spatial-navigation/issues/35#issuecomment-371702434">Issue 35</a>
Expand Down Expand Up @@ -171,13 +170,13 @@ the specification exposes Javascript APIs and Events that enable authors to inte

#### JS APIs

* getSpatnavContainer()
* getSpatialNavigationContainer()
- Returns the spatial navigation focus container of an element.

* focusableAreas()
- Returns all focusable elements within a spatial navigation focus container.

* spatNavSearch()
* spatialNavigationSearch()
- Runs the spatial navigation step and returns the best candidate which will gain the focus.

#### Navigation Events
Expand Down Expand Up @@ -209,7 +208,7 @@ document.addEventListener("navbeforescroll", function(e) {
if (areas.length == 0)) { return; }

e.preventDefault();
var t = e.target.spatNavSearch({
var t = e.target.spatialNavigationSearch({
dir: e.dir,
candidates: areas
});
Expand Down Expand Up @@ -280,11 +279,11 @@ You could achieve the same effect by wrapping the table in a div
and using the overflow property on the div to make it scrollable,
but that has side effects you probably do not want.

### Maybe authors could create "spatnav containers" with JavaScript instead? Could they listen for spat nav events to cancel (=preventDefault) the navigation? Such an event could give authors even more freedom: they might wanna grab the event and manually put focus somewhere else (to override the spatnav's default choice). Would such event allow authors to "patch" the default algorithm in a more flexible way?
### Maybe authors could create "spatial navigation containers" with JavaScript instead? Could they listen for spat nav events to cancel (=preventDefault) the navigation? Such an event could give authors even more freedom: they might wanna grab the event and manually put focus somewhere else (to override the default choice of the spatial navigation). Would such event allow authors to "patch" the default algorithm in a more flexible way?

Yes, they absolutely could.
We have prepared the spec with an event model that lets js authors take control,
and override the default spatnav also to do anything they like.
and override the default spatial navigation also to do anything they like.
That could indeed be used to manually create spatial navigation containers other than documents or scrollers.

We had various idea for other controls to influence what gets the focus,
Expand All @@ -293,7 +292,7 @@ and we decided to leave these out because they could indeed be left to JS
and be added later with declarative syntax if there was strong demand.

However, we still included this property, because:
1. This is trivial to add to the spec (and presumably, to implementations as well), since the concept of looking for a container and searching for focusable things inside it is built-in into the spatnav logic, and we're merely exposing a hook to add additional containers
1. This is trivial to add to the spec (and presumably, to implementations as well), since the concept of looking for a container and searching for focusable things inside it is built-in into the spatial navigation logic, and we're merely exposing a hook to add additional containers
2. Recreating that logic in JS if you're fine with everything else could be quite fiddly
3. It seems like a fairly basic need

Expand All @@ -305,7 +304,7 @@ We initially wanted to make it automatic for limiting the number of things autho

The primary concern was that this involved a particularly expensive form of hit testing that is not used anywhere else on the platform. The secondary reason was that people already need to get the same thing right for sequential navigation, so reinforcing the message was judged useful.

### How can we move the focus inside a spatnav container?
### How can we move the focus inside a spatial navigation container?
There is possible to have nested focusable elements in a web page. The most typical case for this is an ordinary focusable element (button, link, etc) is inside a scroller, as the scroller is also focusable.
If the currently focused element is the scroller, how can we reach the element inside the scroller with key pressing?

Expand Down
Loading

0 comments on commit 26e9a69

Please sign in to comment.