You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: explainer.md
+58-22Lines changed: 58 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,4 @@
1
1
# Proposed Model and APIs for spatial navigation
2
-
3
2
## Introduction
4
3
5
4
Historically, most browsers have not offered features to let users move the focus directionally.
@@ -12,35 +11,75 @@ such as pressing the <code class=key>Shift</code> key together with arrow keys.
12
11
This ability to move around the page directionally is called <strong>spatial navigation</strong>
13
12
(or <strong>spatnav</strong> for short).
14
13
15
-
Spatial navigation can be useful for a webpage built using a grid-like layout,
16
-
or other predominantly non linear layouts.
17
-
The figure below represents a photo gallery arranged in a grid layout.
18
-
If the user presses the <codeclass=key>Tab</code> key to move focus,
19
-
they need to press the key many times to reach the desired element.
20
-
Also, the grid layout may arrange the layout of elements independently of their source order.
21
-
Therefore sequential navigation using the <codeclass=key>Tab</code> key makes focus navigation unpredictable.
22
-
In contrast, <a>spatial navigation</a> moves the focus among focusable elements
23
-
depending on their position
24
-
allowing it to address problems encountered with sequential navigation.
14
+
## What are we going to solve?
15
+
16
+
### Supporting spatial navigation on a web page by default
17
+
18
+
-**Getting devices whose only or primary means of navigation is the D-pad**
19
+
20
+
Devices like TV, ßIVI, game console mainly use the D-pad for navigating focus directionally.
21
+
In the future, the input mechanism such as voice command, hand gesture, eye gazing can be used for navigation.
22
+
23
+
-**Making life better for users of desktop browsers who use keyboard to navigate**
24
+
25
+
For non sighted users, spatial navigation may not be in high demand. But for users who have the visual impairment which may be corrected with glasses, using keyboard can be much preferable to using mouse.
26
+
27
+
-**Using the simple and predictable spatial navigation**
28
+
29
+
If spatial navigation become default in the browser, it will be easier for authors to implement a web page using this feature without having to write custom navigation code.
30
+
Also it ensures the predictable result and reasonable performance of spatial navigation rather than using frameworks which are quite heavy and slow and don't consider all the diversity of use cases.
31
+
32
+
### Allowing authors to override the default spatial navigation behavior
33
+
34
+
Spatial navigation is intended to identify the most-likely desired element in the direction of the key press. But "most-likely desired" can depend on the situation.
35
+
Our proposal is possible to provide a behavior that performs well in most cases, but it will not be right for all cases. Hence the overriding APIs let authors tune and tweak the default spatial navigation behavior for their intention.
36
+
37
+
### Motivating Use cases
38
+
#### Moving focus to the desired element quickly
39
+
How are we going to look through all elements quickly on a webpage?
40
+
There are use cases such as:
41
+
-**Using a grid-like layout**
25
42
26
-
<imgalt="Illustration of a layout which benefits from spatial navigation"src="images/spatnav-enable.png"style="width: 500px; margin: auto; display: block"/>
43
+
The figure below represents a photo gallery arranged in a grid layout.
44
+
If the user presses the <codeclass=key>Tab</code> key to move focus,
45
+
they need to press the key many times to reach the desired element.
46
+
Also, the grid layout may arrange the layout of elements independently of their source order.
47
+
Therefore sequential navigation using the <codeclass=key>Tab</code> key makes focus navigation unpredictable.
48
+
In contrast, <a>spatial navigation</a> moves the focus among focusable elements
49
+
depending on their position
50
+
allowing it to address problems encountered with sequential navigation.
27
51
28
-
While arrow keys are naturally suited to control spatial navigation,
29
-
pressing them (on devices that have such keys)
30
-
has generally triggered other behavior,
31
-
such as scrolling.
52
+
-**Having too much focusable elements**
53
+
54
+
Sometimes user don't want to navigate all focusable elements on a web page. If the user just want to move focus to <code><input></code> elements, they need to keep pressing the <codeclass=key>Tab</code> key until the focus reaches one of those.
55
+
On the other hand, <a>spatial navigation</a> can move focus to <code><input></code> elements only using overriding APIs.
56
+
57
+
58
+
#### Moving focus just as authors intended
59
+
60
+
How do we ensure the correct element is focused?
61
+
There are some use cases which need interrupting the default spatial navigation and custom handling if necessary.
62
+
63
+
-**Navigating to the offscreen element within scrollport directly**
64
+
65
+
There may be a desire about moving the focus to a hidden element while the user is using spatial navigation on a scrollable area. The default behavior of pressing the arrow key is scrolling if there isn’t any visible element in the scrollport. When the hidden element comes into the view, then it can gain the focus. But with proposing overriding APIs, the author can interrupt the default behavior and move the focus directly to it without scrolling.
66
+
67
+
68
+
## How are we going to solve?
32
69
33
70
The [specification of spatial navigation](https://wicg.github.io/spatial-navigation/) introduces the processing model for spatial navigation which explains the default spatial navigation behavior.
34
71
Also, it proposes Javascript APIs, Javascript Events, and a CSS property
35
72
to extend how spatial navigation work.
36
73
37
-
##Processing model of Spatial Navigation
74
+
### Activating Spatial Navigation
38
75
The spec supposes that User Agents decide to activate spatial navigation.
39
76
On devices which do not have any pointing input device,
40
77
and especially on devices such as TVs which also lack a <code>Tab</code> key to control
User Agents should make spatial navigation active.
43
80
81
+
### Processing model
82
+
44
83
When spatial navigation is active,
45
84
pressing an arrow key will either
46
85
move the focus from its current location to a new focusable item in the direction requested,
@@ -90,10 +129,8 @@ element of the author's choosing.
90
129
91
130
The detailed behavior is described in the [Processing Model](https://wicg.github.io/spatial-navigation/#processing-model).
92
131
93
-
## Overriding the heuristic algorithm
94
-
Developers may want to customize the spatial navigation by overriding the heuristic spatial navigation.
95
-
96
-
### Approach proposed by the current specification
132
+
### Overriding the heuristic algorithm
133
+
Authors may want to customize the spatial navigation by overriding the heuristic spatial navigation.
97
134
98
135
Following the principles of [The Extensible Web Manifesto](https://github.com/extensibleweb/manifesto),
99
136
the specification exposes Javascript APIs and Events that enable authors to interact with, and if necessary, override the behavior of spatial navigation.
@@ -198,7 +235,6 @@ However, we still included this property, because:
198
235
## Demo
199
236
-[Blog using the spatial navigation polyfill](https://wicg.github.io/spatial-navigation/demo/blog/)
200
237
201
-
## Sample
202
238
-[Samples using the spatial navigation polyfill](https://wicg.github.io/spatial-navigation/sample/)
203
239
204
240
-[Samples for testing the implementation in Blink](https://wicg.github.io/spatial-navigation/blink_impl/heuristic_default_move.html)
0 commit comments