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

aim

v0.1.6

Published

Dependency free focus manager with built-in universal key navigation.

Downloads

8

Readme

Aim

Dependency free focus manager with built-in universal key navigation.

npm i --save aim

What?

Register your focusable targets with Aim and Aim will map these into a virtual table-esque view.

Aim will now listen for key events, delegate these to the currently focused target and execute default cursor navigation if not prevented by target handlers.

Examples

aim.register({
  onFocus (target) {
    // fires when target is focused
    // return false to prevent focus
  },
  onBlur (target) {
    // fires when target is unfocused 

  },
  onRight (target) {
    // fires when right is pressed
    // return false to prevent default behaviour (ie. moving cursor to the right)
  },
  onEnter (target) {
    // fires when enter is pressed
  }
}, [0, 0, 1])

Methods

aim.register(target, position)

Registers target on given position.

| Param | Type | Description | | --- | --- | --- | | target | Object | Target containing handlers. | | position | Array | Coordinates for position. |

aim.unregister(target)

Unregisters target.

| Param | Type | Description | | --- | --- | --- | | target | Object | Target to unregister. |

aim.update(target, property, value)

Update properties for given target. Can be used for repositioning / resizing targets.

| Param | Type | Description | | --- | --- | --- | | target | Object | Target to update. | | property | String | Property to update, eg. x or y. | | value | Number | New value of property |

aim.offsetY(target, value)

Sets an offsetY value to (holder) target, without updating all individual child nodes. Will be used when calculating left/up/down/right node.

| Param | Type | Description | | --- | --- | --- | | target | Object | Target to update. | | value | Number | New value of property |

aim.offsetX(target, value)

Same as aim.offsetY() for the x axis.

aim.get(position)

Get target by position.

| Param | Type | Description | | --- | --- | --- | | position | Array | The coordinates to target (eg. [0, 0, 1]). |

aim.left()

Move focus to the left.

aim.up()

Move focus to up.

aim.right()

Move focus to the right.

aim.down()

Move focus to down.

aim.handleKeyEvent(event)

Delegate key event to Aim.

| Param | Type | Description | | --- | --- | --- | | event | Object | DOM KeyEvent. |

Events

onFocus(target)

Fires when target is focused.

| Param | Type | Description | | --- | --- | --- | | target | Object | Registered target. |

onBlur(target)

Fires on target when removing focus.

| Param | Type | Description | | --- | --- | --- | | target | Object | Registered target. |

onEnter(target)

Fires on focused target when user presses "enter".

| Param | Type | Description | | --- | --- | --- | | target | Object | Registered target. |