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

marking-menu

v0.10.0

Published

Marking Menu Implementation in JavaScript.

Downloads

23

Readme

Marking Menu

NPM Build Status codecov

This library is an implementation of Gordon Kurtenbach's infamous Marking Menus in JavaScript [1, 2, 3].

Have a look at the demo.

License

This codebase is licensed under the MIT license. However, Marking Menus are concerned by several patents, none of which are owned by the author of this library. Make sure you have the rights to include this library in your application before doing so. The authors and contributors of this library may not be held responsible for any patent infringement following the use of this codebase.

Dependencies

Install

Browser with CDN

You can use unpkg to fetch both rxjs and marking-menu:

  • https://unpkg.com/rxjs@7/dist/bundles/rxjs.umd.js,
  • https://unpkg.com/marking-menu,
<!DOCTYPE html>
<html>
  <head>
    <script
      src="https://unpkg.com/rxjs@7/dist/bundles/rxjs.umd.js"
      defer
    ></script>
    <script src="https://unpkg.com/marking-menu" defer></script>
    <script defer>
      // Your stuff.
    </script>
  </head>
  <body></body>
</html>

ES modules or CommonJS

npm install -S marking-menu

Then (ES modules)

import MarkingMenu from 'marking-menu';

or (CommonJS)

var MarkingMenu = require('marking-menu');

API

MarkingMenu(items, parentDOM): Observable

MarkingMenu returns a 'hot' Observable that emits notification of the form { name, angle }. The menu is activated upon subscription of this observable, and disabled upon un-subscription.

  • items: Array of string or { name, children }. The list of the menu's items. If children is provided, the item will be considered as a sub-menu (children has the same form as items). Currently, MarkingMenu supports up to 8 items per level. The first item is on the right and the followings are layed out clockwise.

  • parentDOM: HTMLElement. The container of the menu.

Example

// Create the menu with a sub-menu at the bottom.
const items = [
  'Item Right',
  {
    name: 'Others...',
    children: ['Sub Right', 'Sub Down', 'Sub Left', 'Sub Top'],
  },
  'Item Left',
  'Item Up',
];
const mm = MarkingMenu(items, document.getElementById('main'));

// Subscribe (and activates) the menu.
const subscription = mm.subscribe((selection) => {
  // Do something.
  console.log(selection.name);
});

setTimeout(() => {
  // Later, disable the menu.
  subscription.unsubscribe();
}, 60 * 1000);