# vue-js-spatial-navigation

> Vue directive of js-spatial-navigation

Latest version **2.0.14** (published 2022-01-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install vue-js-spatial-navigation
pnpm add vue-js-spatial-navigation
yarn add vue-js-spatial-navigation
bun add vue-js-spatial-navigation
```

## 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 | 2.0.14 |
| Published | 2022-01-06 |
| First published | 2020-08-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 43.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Brandon.gh.yang |
| Maintainers | brandon.gh.yang |
| Keywords | vue, spatial-navigation, smart-tv, key-navigation |

## Links

- npm: https://www.npmjs.com/package/vue-js-spatial-navigation
- Repository: https://github.com/spacerefugee/vue-js-spatial-navigation
- Homepage: https://github.com/spacerefugee/vue-js-spatial-navigation#readme
- Issues: https://github.com/spacerefugee/vue-js-spatial-navigation/issues
- npm.io page: https://npm.io/package/vue-js-spatial-navigation

## Dependencies (2)

- [focus-options-polyfill](https://npm.io/package/focus-options-polyfill.md) ^1.6.0
- [scroll-behavior-polyfill](https://npm.io/package/scroll-behavior-polyfill.md) ^2.0.13

## 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

- 2.0.14 (latest) — 2022-01-06
- 2.0.13 — 2020-11-20
- 2.0.12 — 2020-10-21
- 2.0.11 — 2020-10-20
- 2.0.10 — 2020-10-12
- 2.0.9 — 2020-09-30
- 2.0.8 — 2020-09-28
- 2.0.7 — 2020-09-25
- 2.0.6 — 2020-09-25
- 2.0.5 — 2020-09-24
- 2.0.4 — 2020-09-15
- 2.0.3 — 2020-09-13
- 2.0.2 — 2020-09-11
- 2.0.1 — 2020-09-09
- 2.0.0 — 2020-09-08
- … 2 more at https://npm.io/package/vue-js-spatial-navigation/versions

## README

# vue-js-spatial-navigation [![npm version](http://img.shields.io/npm/v/vue-js-spatial-navigation.svg?style=flat)](https://npmjs.org/package/vue-js-spatial-navigation "View this project on npm")

Vue directive of [js-spatial-navigation](https://github.com/luke-chang/js-spatial-navigation);

## Installation

### NPM

```shell
    npm install vue-js-spatial-navigation
```

## Getting Started

```javascript
import Vue from "vue";
import vjsn from "vue-js-spatial-navigation";

Vue.use(vjsn);
```

#### 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`.

```javascript
const config = {
  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(vjsn, config);
```

## Documentation

### `$SpatialNavigation`

A global Vue instance property for [SpatialNavigation](https://github.com/luke-chang/js-spatial-navigation#api-reference);

```javascript
// you can access SpatialNavigation in every instance
this.$SpatialNavigation;
```

### `v-focus`

A directive that make the element focusable.

The element with `v-focus` must under the element with `v-focus-section`, see [v-focus-section](#v-focus-section)

```html
<div v-focus>
  <div></div>
</div>
```

#### dynamic control

```html
<div v-focus="focusable">
  <div></div>
</div>

<script>
  export default {
    data() {
      return {
        focusable: false
      };
    },
    methods: {
      changeFocusable() {
        this.focusable = !this.focusable;
      }
    }
  };
</script>
```

### `v-focus-section`

A directive that define a focus [Section](https://github.com/luke-chang/js-spatial-navigation#spatialnavigationaddsectionid-config)

```html
<div v-focus-section>
  <div v-focus>
    <div></div>
  </div>
  <div v-focus>
    <div></div>
  </div>
</div>
```

#### Pass a specified section id

```html
<!-- section id -->
<div v-focus-section:my-section>
  <div v-focus></div>
</div>
```

#### Set configuration

```html
<!-- set configuration -->
<div v-focus-section:my-section="{enterTo:'last-focused'}">
  <div v-focus></div>
</div>
```

#### Set default section

```html
<!-- set default section -->
<div v-focus-section:my-section.default="{enterTo:'last-focused'}">
  <div v-focus></div>
</div>
```

### `v-disable-focus-section`

This directive will make the conponemt unnavigable.
See [SpatialNavigation.disable()](https://github.com/luke-chang/js-spatial-navigation#spatialnavigationdisablesectionid),
[SpatialNavigation.enable()](https://github.com/luke-chang/js-spatial-navigation#spatialnavigationenablesectionid).

```html
<div v-focus-section v-disable-focus-section="disable">
  <div v-focus></div>
</div>

<script>
  export default {
    data() {
      return {
        disable: false
      };
    },
    methods: {
      changeDisable() {
        this.disable = !this.disable;
      }
    }
  };
</script>
```

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