Spatial Navigation in Angular
npm i ngx-spatial-navigation
Import the NgxSpatialNavigationModule
module into your AppModule
:
import { NgxSpatialNavigationModule } from "ngx-spatial-navigation";
@NgModule({
imports: [NgxSpatialNavigationModule],
})
export class AppModule {}
Add the navRoot
and navFocusable
directives to your template:
<div navRoot>
<div navFocusable>First element</div>
<div navFocusable>Second element</div>
<div navFocusable>Third element</div>
</div>
You can now navigate through the elements using the arrow keys on your keyboard.
The navRoot
directive is used to mark the root element where navigation will take place. There must be only one in the application.
The navSection
directive is needed to combine elements into a section.
ignore
- Iftrue
, the section element will not be considered focusable and will be skipped over.
The navFocusable
directive is used to mark elements that can be focusable.
ignore
- Iftrue
, the element will not be considered focusable and will be skipped over.
MIT. Copyright (c) Kyaw Swar Thwin <[email protected]>