Re: [csswg-drafts] [css-nav-1] How author know spatnav will work by default in specific user agent? (#3385)

---

Migrated from https://github.com/WICG/spatial-navigation/issues/41#issuecomment-430148006
Originally created by @jihyerish on *Tue, 16 Oct 2018 08:27:09 GMT*

---
How about considering this by defining the new interface?
Such as, "`SpatialNavigator`" interface.

The `SpatialNavigator` interface of the spatial navigation which manages the process of spatial focus navigation on the web page.
Be specific,
- Constructor
  - SpatialNavigator(): Creates a new SpatialNavigator object.

- Event Handlers
  - SpatialNavigator.navbeforefocus: Dispatched when the spatial navigation process finds the best candidate.
  - SpatialNavigator.navbeforescroll: Dispatched when the spatial navigation triggers scrolling.
  - SpatialNavigator.navnotarget: Dispatched when the spatial navigation fails for finding the best candidate.

On top of that, the APIs in the current spatial navigation spec can be combined with this.

In this sense, the developer can know whether the page supports spatial navigation or not.
For example,
```js
if (window.SpatialNavigator) {
  // The spatial navigator is supported
} else {
  // The spatial navigator is not supported
}
```
Also, the developer creates a `SpatialNavigator` to build a web page which uses the spatial navigation APIs.

-- 
GitHub Notification of comment by frivoal
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3385#issuecomment-443619116 using your GitHub account

Received on Monday, 3 December 2018 07:53:09 UTC