vue-spatial-nav

Vue 3 directives for spatial navigation
4,538 12
Install
npm install vue-spatial-nav
Latest Version:1.0.11
Vue:3
License:MPL-2.0
Last Updated:Jan 22, 2024
Links: GitHub  ·  npm
Maintainer: cedroux

Vue Spatial Navigation

npm

Forked from Syncronet-APS/zome-vjsn and spacerefugee/vue-js-spatial-navigation
Original author luke-chang

Vue directive of 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

npm install vue-spatial-nav

Getting Started

import vueSpatialNavigation from 'vue-spatial-nav';

app.use(vueSpatialNavigation);
Optional global Configuration
Additional configuration scrollOptions:
  • The page will auto scroll to the focus element by using scrollIntoView.

  • You can set this scrollOptions for the scrollIntoViewOptions.

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

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

You can access SpatialNavigation in every instance

this.$SpatialNavigation;

or with the inject() function

<script setup>
import { inject } from 'vue';

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

v-focus

v-focus-events

v-focus-section

v-disable-focus-section

Related Packages

vuepg

Vue 2.7 / Vue 3 焦点管理与空间导航,支持键盘与遥控器,适用于现代浏览器、TV、IPTV...

2,116 8
vue-device-detect

检测设备类型,根据设备类型渲染内容

11,490
vue

The progressive JavaScript framework for building modern web UI.

588,019,132 54,801
vue
@vueuse/shared
372,738,348 22,398
@vueuse/core

Collection of essential Vue Composition Utilities

367,188,523 22,398

Version History

Version Released Vue License
1.0.11 ^3.2.0 MPL-2.0
1.0.10 ^3.2.0 MPL-2.0
1.0.9 ^3.2.0 MPL-2.0
1.0.6 ^3.2.0 MPL-2.0
1.0.5 ^3.2.0 MPL-2.0