npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

naviix

v1.1.0

Published

Spatial navigation. Arrow key navigation.

Downloads

18

Readme

naviix

naviix 可以辅助实现键盘的空间导航(方向键聚焦导航)。输入元素(或坐标尺寸),输出每个元素的上、下、左、右方向上的相邻元素。具体效果请访问一个线上🎵音乐主题范例:naviix music

Chrome 中,在地址栏输入 chrome://settings/accessibility,或者在“设置 -> 无障碍”中,可以设置“短暂地突出显示焦点对象”。其它浏览器也许有类似的设定。

Chrome Outer Row

安装和使用

使用 npm 安装最新版本(yarn 则是 yarn add naviix):

npm install naviix

使用格式:

const res = naviix(rectangles);

具体范例:

import navix from "naviix";
const r1 = document.getElementById("r1"); // 矩形 r1 元素(假设坐标尺寸为 [1, 1, 1, 1])
const r2 = [4, 1, 1, 1]; // 矩形 r2 的坐标尺寸
const nxMap = navix([r1, r2]);
const r1Right = nxMap.get(r1).right; // r1 的右方元素
const r2Left = nxMap.get(r2).left; // r2 的左方元素

参数

  • rectangles,数组或对象,代表所有矩形,当矩形都固定在同一平面中时,选择数组格式,否则选择对象。

数组格式范例:

const rectangles = [
  document.getElementById("r1"),
  { "id": "r2", "loc": [4, 1, 1, 1] }
]

简写形式为 [document.getElementById("r1"), [4, 1, 1, 1]]

  • loc元素或坐标尺寸数字数组,数组前两个数字表示矩形中心坐标,第 3、4 个数字表示中心距离竖边与横边的距离,而元素会在内部被转为数字数组;
  • id 作为唯一值代表了某个矩形,可以是任何值,当忽略 id 时,naviix 会主动将 loc 填充为 id
{
  "locs": [{ "id": "s1", "loc": [1, 5, 1, 1] }],
  "subs": {
    "locs": [
      { "id": "s2", "loc": [5, 1, 1, 1] },
      { "id": "s3", "loc": [5, 4, 1, 1] }
    ],
    "wrap": { "id": "w", "loc": [5, 3.5, 2, 3.5] }
  }
}
  • 当包含 subs 子区时,wrap 是必须的,表示子区的包裹层的坐标尺寸信息,wrap 也可以是 Element 对象元素。

对象格式中,同样支持简写形式。

返回值

返回值是一个 MapMap 的键是输入参数中的 id,值是一个包含 up/right/down/left 四个属性的对象,属性值为 undefined 表示该方向没有相邻矩形,否则值是一个形如 { id: "", loc: [] } 的对象。

const r1 = document.getElementById("r1"); // [1, 1, 1, 1]
const r2 = document.getElementById("r2");
const nxMap = navix([r1, {
  id: r2,
  loc: [4, 1, 1, 1]
}]);
nxMap.get(r1).right.id.focus(); // nxMap.get(r1).right.id === r2

上面代码块中,返回值 nxMap 的结构如下:

Map(2) {
  r1 => {
    up: undefined,
    right: { id: r2, loc: [4, 1, 1, 1] },
    down: undefined,
    left: undefined
  },
  r2 => {
    up: undefined,
    right: undefined,
    down: undefined,
    left: { id: r1, loc: [1, 1, 1, 1] }
  }
}

单元测试与参与开发

npm install
npm run test

参与开发,一起让程序的变量命名更合适、性能和功能更好。修改源码后,编写并执行相关单元测试,验证是否输出了预期的结果。项目中的原理文件(how-it-works.md)也许能提供一定帮助。

支持与赞助

点亮星星、提出问题、请求合并来推动这个项目!

您可以支付该项目,支付金额由您从该项目中获得的收益自行决定。

日志、版本规则、协议和其它

相关资源:


Demo更新日志语义化版本 2.0.0MPL-2.0 License