Skip to content

[css-nav-1] Predefined algorithm for spatial navigation #3964

@jihyerish

Description

@jihyerish

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 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 for the default spatial navigation behavior in the spec was decided depending on UX test cases.
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
  • 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.
  • Inherited: Yes

This demo shows how this property works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions