NoriginMedia / react-spatial-navigation

DEPRECATED. HOC-based Spatial Navigation. NEW Hooks version is available here: https://github.com/NoriginMedia/norigin-spatial-navigation
MIT License
226 stars 64 forks source link

Need to add setFocusByDirection("left", "right", "top" or "bottom") #34

Closed yarikleto closed 5 years ago

yarikleto commented 5 years ago

When I handle the wheel event, I need to move to the top or bottom (I won't use focus by keys).

We can use a smartNavigate method of the SpatialNavigation class.

onKeyEvent(keyCode) {
    this.visualDebugger && this.visualDebugger.clear();

    const direction = findKey(this.getKeyMap(), (code) => keyCode === code);

    this.smartNavigate(direction); // We can use it
}
salvan13 commented 5 years ago

Hi @alfimois Usually mouse wheel doesn't change focus on elements, not sure if we should add this. Can you explain your use case step by step?

yarikleto commented 5 years ago

Added by that PR https://github.com/NoriginMedia/react-spatial-navigation/pull/36

salvan13 commented 5 years ago

Thanks! So basically you need a method for navigate in a certain direction programmatically. Right?

In this case I would call it navigateTo(direction) or focusNext(direction) instead of smartNavigateByDirection(direction) (since smartNavigate is not used in the public api).

what do you think @asgvard ?

salvan13 commented 5 years ago

@alfimois also please when you open a pull request don't mix things: like refactoring + new feature. Let's keep pull request minimal and focus on one thing. Thanks!

asgvard commented 5 years ago

@salvan13 Perhaps navigateByDirection is a good name. Because "navigateTo" might mean "navigate to some place" instead of direction. Also "focusNext" might mean it focuses some component. @alfimois I'll add some comments to PR in a minute

yarikleto commented 5 years ago

Let's keep pull request minimal and focus on one thing. @salvan13 OK, sry)

yarikleto commented 5 years ago

Usually mouse wheel doesn't change focus on elements, not sure if we should add this. Can you explain your use case step by step?

Our TVs can change focusing by a wheel on the remote ;)

yarikleto commented 5 years ago

Added https://github.com/NoriginMedia/react-spatial-navigation/pull/36