This is lightweight and zero dependencies pure javascript library for modern web browser. https://winetree94.github.io/VanillaContextMenu
Find a file
2020-11-14 12:57:30 +00:00
.github/workflows 20201114 2020-11-14 21:04:15 +09:00
.storybook 20200319 storybook init 2020-03-20 00:06:26 +09:00
.vscode 20200425 2020-04-25 22:44:22 +09:00
docs commit docs 2020-11-14 12:57:30 +00:00
public update test mode 2020-11-14 21:33:57 +09:00
src fix mouse position error 2020-11-14 21:56:01 +09:00
.eslintrc.js 20200319 docsify init 2020-03-19 21:45:00 +09:00
.gitignore 20201114 2020-11-14 20:47:34 +09:00
.prettierignore 20200105 2020-01-05 21:37:23 +09:00
.prettierrc 20200118 2020-01-18 15:58:58 +09:00
LICENSE 20200114 add license and readme 2020-01-14 23:06:02 +09:00
package-lock.json update dependencies 2020-11-13 15:40:37 +09:00
package.json update version 2020-11-14 21:56:21 +09:00
README.md update version 2020-11-14 21:56:21 +09:00
tsconfig.json fix module problems 2020-11-13 16:08:38 +09:00
webpack.dev.js 20200119 2020-01-19 16:48:06 +09:00
webpack.prod.js update dependencies 2020-11-13 15:40:37 +09:00

CI

Pure Javascript Context Menu

This is lightweight and zero dependencies pure javascript library for modern web browser.


in browser

<!-- using cdn -->
<link rel="stylesheet" href="https://unpkg.com/vanilla-context@1.0.13/dist/vanilla-context.min.css">
<script src="https://unpkg.com/vanilla-context@1.0.13/dist/vanilla-context.min.js"></script>
const table = document.getElementById('table');
const options = {...};
const context = new VanillaContext(table, options);

in node.js

import { VanillaContext } from 'vanilla-context';
import 'vanilla-context/dist/vanilla-context.min.css';

const table = document.getElementById('table');
const options = {...};
const context = new VanillaContext(table, options);

Option interface

interface VanillaContextOptions {
  debug?: boolean;
  autoClose?: boolean;
  nodes: ContextNode[] | ((e: Event) => ContextNode[]);
}

ContextNode Interface

interface ContextNode {
  renderer: Renderer;
  onClick: (params: ContextNodeEventParams) => void;
  children?: ContextNode[];
  disabled?: boolean | ((params: ContextDisabledParams) => boolean);
  height?: number | ((params: ContextHeightParams) => number);
}

ContextNode callback parameter interfaces

click event callback function parameters interface

export interface ContextNodeEventParams {
  api: VanillaContext;
  event: Event;
  originEvent: Event;
}

disabled callback function parameters interface

export interface ContextDisabledParams {
  api: VanillaContext;
  originEvent: Event;
}

height callback function parameters interface

export interface ContextHeightParams {
  api: VanillaContext;
  originEvent: Event;
}

Renderer

you can use any type of renderer. string, function and class will works well

Renderer Interface

interface RendererInterface {
  init: (params: RendererParams) => void;
  getLayout: () => Node;
  destroy: () => void;
}