NoriginMedia / Norigin-Spatial-Navigation

React Hooks based Spatial Navigation (Key & Remote Control Navigation) / Web Browsers, Smart TVs and Connected TVs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Export `navigateByDirection`

ChocolateLoverRaj opened this issue · comments

Is your feature request related to a problem? Please describe.
I want to do navigation with a gamepad

Describe the solution you'd like
Export navigateByDirection, like the other methods are exported.

Describe alternatives you've considered
Current work-around:

import { SpatialNavigation } from '@noriginmedia/norigin-spatial-navigation'

declare module '@noriginmedia/norigin-spatial-navigation' {
  const SpatialNavigation: any
}

Additional context
Related to #67

commented

Hello @ChocolateLoverRaj.

Thanks for your contribution.

When it comes to navigateByDirection, this is already exposed through the useFocusable hook, as you can see here: https://github.com/NoriginMedia/Norigin-Spatial-Navigation/blob/main/src/useFocusable.ts#L208

This is also mentioned here: https://github.com/NoriginMedia/Norigin-Spatial-Navigation#top-level-exports

You can also directly call it on the service:

import { SpatialNavigation } from '@noriginmedia/norigin-spatial-navigation'

..
SpatialNavigation.navigateByDirection(..); // This works too
..

So I believe what you are requesting is already there. As such I will close this as "Won't fix".

Thanks.

@predikament The code you commented:

import { SpatialNavigation } from '@noriginmedia/norigin-spatial-navigation'

This creates a typescript error because SpatialNavigation isn't exported in the TypeScript definitions.

commented

Hello again, @ChocolateLoverRaj

OK, I see what you mean - We've discussed this as part of what should be exposed and have chosen not to expose the service itself in this way, as it can cause it to be interacted with in unintended ways.

If you need any functionality that is not exposed through the hook then let us know. Thanks!