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 🙏

© 2024 – Pkg Stats / Ryan Hefner

focus-rover

v2.0.5

Published

Set a roving focus on a group of elements.

Downloads

91

Readme

focus-rover

Set a roving focus on a collection of elements. Useful for composite widgets and promoting better keyboard user experiences.

See https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_roving_tabindex for more info about roving tabindex.

Usage

To get started, install the package through NPM and include it in your project. It is a UMD package, so it will work in both Node and the browser.

npm install focus-rover
// (Node.js)
const FocusRover = require('focus-rover');

const rover = new FocusRover();
rover.addElement(document.getElementById('my-first-element'));
rover.addElement(document.getElementById('my-second-element'));
rover.addElement(document.getElementById('etc'));

To save you some time, three static methods are provided to get your roving started!

API

Three static methods are provided to initialize your collection of rovable elements.

// from a CSS selector
let rover = FocusRover.fromSelector('li>a');

// from an existing NodeList
rover = FocusRover.fromNodeList(document.querySelectorAll('li>a'));

// from a collection of elements
const anchor1 = document.getElementById('a1');
const anchor2 = document.getElementById('a2');
const anchor3 = document.getElementById('a3');
rover = FocusRover.fromElements(anchor1, anchor2, anchor3);

// let FocusRover figure out what you mean
rover = FocusRover.from('li>a');
rover = FocusRover.from(document.querySelectorAll('li>a'));
rover = FocusRover.from(anchor1, anchor2, anchor3);

When the user focuses on any of the elements in the collection, they can then move through them with arrow keys. The next tab press will exit the group.

Configuration

All FocusRover instances will follow the static FocusRover.config, which can be modified with FocusRover.configure(userConfig), where userConfig can override any of the options in the default config.