[csswg-drafts] [css-nav-1] Predefined algorithm for spatial navigation (#3964)

jihyerish has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-nav-1] Predefined algorithm for spatial navigation ==
When we first introduced spatial navigation, I also had suggested some features that can customize the default spatial navigation behavior.
One of those was [`nav-rule`](https://github.com/WICG/spatial-navigation/wiki/Proposal-of-spatial-navigation-on-TPAC-2017#nav-rule-property-cssui4) which changes the default focus navigation algorithm(or function).

I'd like to bring this up again. 
It would be helpful for the author to use the predefined function which is used for deciding what will be the most desirable element to move the focus next among candidate elements.

The [distance function](https://drafts.csswg.org/css-nav-1/#find-the-shortest-distance) for the default spatial navigation behavior in the spec was decided depending on [UX test cases](https://wicg.github.io/spatial-navigation/tests/ux/list.html).
In certain cases which aren't counted in the test cases, other algorithms suit better than the default.
For example, for the page perfectly filled within a grid layout.
Moving the focus to the closest element only considering the one axis corresponding to navigation direction would be more reasonable. (If the right or left arrow key is pressed, only consider the distance along the x-axis.)
To define the distance function like this is straightforward and it may be used frequently.

Therefore the CSS property which can specify the predefined distance function would be useful.
The author doesn't have to implement such functions.

It would be defined as below:

```
spatial-navigation-function: normal | grid | euclidean
```
- Value:
  - normal: Moves the focus with the default focus navigation algorithm defined by UA
  - grid: Moves the focus to the closest element only considering the one axis which corresponds to the direction of navigation.
  - euclidean: Moves the focus to the closest element based on the euclidean distance
- Applied to: spatial navigation container
- Inherited: Yes

[This demo](https://raw.githack.com/WICG/spatial-navigation/develop/demo/calendar/index.html) shows how this property works.

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3964 using your GitHub account

Received on Friday, 24 May 2019 06:56:13 UTC