# vue-spatial-nav

> Vue 3 directives for spatial navigation

Latest version **1.0.11** (published 2024-01-22) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install vue-spatial-nav
pnpm add vue-spatial-nav
yarn add vue-spatial-nav
bun add vue-spatial-nav
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2024-01-22 |
| First published | 2022-11-17 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 66 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | https://github.com/cedroux/vue-spatial-nav/graphs/contributors |
| Maintainers | cedroux |
| Keywords | vue, vue3, spatial-navigation, smart-tv, key-navigation |

## Links

- npm: https://www.npmjs.com/package/vue-spatial-nav
- Repository: https://github.com/cedroux/vue-spatial-nav
- Issues: https://github.com/cedroux/vue-spatial-nav/issues
- npm.io page: https://npm.io/package/vue-spatial-nav

## Alternatives

- [express-promise-router](https://npm.io/package/express-promise-router.md) — 736.1K weekly downloads
- [next-usequerystate](https://npm.io/package/next-usequerystate.md) — 29.8K weekly downloads
- [@bitkyc08/opencodex](https://npm.io/package/@bitkyc08/opencodex.md) — 4.6K weekly downloads
- [lynkr](https://npm.io/package/lynkr.md) — 575 weekly downloads
- [baremetal.js](https://npm.io/package/baremetal.js.md) — 42 weekly downloads

## Recent versions

- 1.0.11 (latest) — 2024-01-22
- 1.0.10 — 2023-06-26
- 1.0.9 — 2023-04-26
- 1.0.6 — 2023-02-07
- 1.0.5 — 2022-11-23
- 1.0.4 — 2022-11-22
- 1.0.3 — 2022-11-18
- 1.0.2 — 2022-11-18
- 1.0.1 — 2022-11-17
- 1.0.0 — 2022-11-17

## README

# Vue Spatial Navigation

[![npm](https://img.shields.io/npm/v/vue-spatial-nav?style=flat-square)](https://www.npmjs.com/package/vue-spatial-nav)

Forked from [Syncronet-APS/zome-vjsn](https://github.com/Syncronet-APS/zome-vjsn) and [spacerefugee/vue-js-spatial-navigation](https://github.com/spacerefugee/vue-js-spatial-navigation) \
Original author [luke-chang](https://github.com/luke-chang/js-spatial-navigation)

### Vue directive of [js-spatial-navigation](https://github.com/luke-chang/js-spatial-navigation)

- Compatible with Vue3
- Added mouse support
- Added enter-up trigger click on focused element
- Added directive 'v-focus-events' for spatial navigation custom events
- Added TS declarations

### Goal

Our goal is to have a library containing the tools you need to create a TV app with Vue for all platforms possible. \
The library has been tested on WebOS, Tizen and Android TV.

## Contribution

Feel free to open issues/pull requests. \
We are open to new features & changes. \
We are willing to answer questions.

## Installation

### NPM

```shell
npm install vue-spatial-nav
```

## Getting Started

```ts
import vueSpatialNavigation from 'vue-spatial-nav';

app.use(vueSpatialNavigation);
```

#### Optional global [Configuration](https://github.com/luke-chang/js-spatial-navigation#configuration)

#### Additional configuration `scrollOptions`:

- The page will auto scroll to the focus element by using [`scrollIntoView`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView).

- You can set this `scrollOptions` for the `scrollIntoViewOptions`.

- The page will not scroll to the focus element when setting `scrollOptions` to `''` or `null`.

```ts
import vueSpatialNavigation from 'vue-spatial-nav';

const globalConfig = {
  straightOnly: false,
  straightOverlapThreshold: 0.5,
  rememberSource: false,
  disabled: false,
  defaultElement: '',
  enterTo: '',
  leaveFor: null,
  restrict: 'self-first',
  tabIndexIgnoreList: 'a, input, select, textarea, button, iframe, [contentEditable=true]',
  navigableFilter: null,
  scrollOptions: {
    behavior: 'smooth',
    block: 'center',
  },
};

Vue.use(vueSpatialNavigation, globalConfig);
```

## Documentation

### Global SpatialNavigation instance

A global Vue instance property for [SpatialNavigation](https://github.com/luke-chang/js-spatial-navigation#api-reference)

You can access SpatialNavigation in every instance
```ts
this.$SpatialNavigation;
```

or with the inject() function
```vue
<script setup>
import { inject } from 'vue';

const spatialNavigation = inject('spatialNavigation');
</script>
```

### [`v-focus`](docs/v-focus.md)

### [`v-focus-events`](docs/v-focus-events.md)

### [`v-focus-section`](docs/v-focus-section.md)

### [`v-disable-focus-section`](docs/v-disable-focus-section.md)

---
_Source: https://npm.io/package/vue-spatial-nav · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
