Security News
Opengrep Emerges as Open Source Alternative Amid Semgrep Licensing Controversy
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
makeup-navigation-emitter
Advanced tools
Emits custom events based on keyboard navigation of one or two dimensional model
A vanilla JavaScript port of jquery-linear-navigation.
Emits custom events based on keyboard navigation of one or two dimensional model.
This module is still in an experimental state, until it reaches v1.0.0 you must consider all minor releases as breaking changes. Patch releases may introduce new features, but will be backwards compatible.
// via npm
npm install makeup-navigation-emitter
// via yarn
yarn add makeup-navigation-emitter
Example support for a roving tabindex model of keyboard navigation.
Note that this module will not change focus, that is the job of an observer such as makeup-roving-tabindex.
<div class="widget">
<ul>
<li tabindex="0">Item 0</li>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>
const NavigationEmitter = require('makeup-navigation-emitter');
const widgetEl = document.querySelector('.widget');
var emitter = NavigationEmitter.createLinear(widgetEl, 'li'));
widgetEl.addEventListener('navigationModelChange', function(e) {
console.log(e.detail.fromIndex, e.detail.toIndex);
});
Example support for an active descendant model of navigation with focus on ancestor of items.
Note that this module will not highlight the active item, that is the job of an observer such as makeup-active-descendant.
<div class="widget" tabindex="0">
<ul>
<li>Item 0</li>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>
const NavigationEmitter = require('makeup-navigation-emitter');
const widgetEl = document.querySelector('.widget');
var emitter = NavigationEmitter.createLinear(widgetEl, 'li', { autoInit: -1, autoReset: -1 }));
widgetEl.addEventListener('navigationModelChange', function(e) {
console.log(e.detail.fromIndex, e.detail.toIndex);
});
Example support for an active descendant model of navigation with focus on non-ancestor of items.
Note that this module will not highlight the active item, that is the job of an observer such as makeup-active-descendant.
<div class="widget">
<input type="text" />
<ul>
<li>Item 0</li>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</div>
const NavigationEmitter = require('makeup-navigation-emitter');
const widgetEl = document.querySelector('.widget');
var emitter = NavigationEmitter.createLinear(widgetEl, 'li', { autoInit: -1, autoReset: -1 }));
widgetEl.addEventListener('navigationModelChange', function(e) {
console.log(e.detail.fromIndex, e.detail.toIndex);
});
autoInit
: specify an integer or -1 for initial index (default: 0)autoReset
: specify an integer or -1 for index position when focus exits widget (default: null)wrap
: specify whether arrow keys should wrap/loop (default: false)axis
: specify 'x' for left/right arrow keys, 'y' for up/down arrow keys, or 'both' (default: 'both')navigationModelInit
- fired when the model is auto initialisednavigationModelChange
- fired when the index is set by any means other than auto init or auto resetnavigationModelReset
- fired when the model is auto resetFor all 3 events, the event detail object contains the fromIndex
and toIndex
.
npm start
npm test
npm run lint
npm run fix
npm run build
npm run clean
The following hooks exist, and do not need to be invoked manually:
npm prepublishOnly
cleans, lints, tests and builds on every npm publish
commandpre-commit
cleans, lints, tests and builds on every git commit
commandEach test run will generate the following reports:
/reports/coverage
contains Istanbul code coverage report/reports/html
contains HTML test reporthttps://travis-ci.org/makeup-js/makeup-navigation-emitter
https://coveralls.io/github/makeup-js/makeup-navigation-emitter
FAQs
Emits custom events based on keyboard navigation of one or two dimensional model
The npm package makeup-navigation-emitter receives a total of 93 weekly downloads. As such, makeup-navigation-emitter popularity was classified as not popular.
We found that makeup-navigation-emitter demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
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.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.