Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aim

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aim

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

  • 0.1.6
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

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.

ParamTypeDescription
targetObjectTarget containing handlers.
positionArrayCoordinates for position.

aim.unregister(target)

Unregisters target.

ParamTypeDescription
targetObjectTarget to unregister.

aim.update(target, property, value)

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

ParamTypeDescription
targetObjectTarget to update.
propertyStringProperty to update, eg. x or y.
valueNumberNew 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.

ParamTypeDescription
targetObjectTarget to update.
valueNumberNew value of property

aim.offsetX(target, value)

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

aim.get(position)

Get target by position.

ParamTypeDescription
positionArrayThe 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.

ParamTypeDescription
eventObjectDOM KeyEvent.

Events

onFocus(target)

Fires when target is focused.

ParamTypeDescription
targetObjectRegistered target.

onBlur(target)

Fires on target when removing focus.

ParamTypeDescription
targetObjectRegistered target.

onEnter(target)

Fires on focused target when user presses "enter".

ParamTypeDescription
targetObjectRegistered target.

FAQs

Package last updated on 09 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc