Giter VIP home page Giter VIP logo

react-contextmenu's Introduction

React ContextMenu @yu

ContextMenu in React.

forked from https://github.com/vkbansal/react-contextmenu

##Feature

you can custeom Icons

callback will return DOM element. img

Installation

npm install --save react-contextmenu-yu

Usage

auto bind to parentNode,auto bind to document

see examples/index.js

you have to add css manually:(webpack)

you need config webpack /*.file.css/ loader

import s from "style!raw!react-contextmenu-yu/modules/default-react-context-menu.file.css"
<div !!!!parentNode!!!!!>
    <ContextMenu  >
        <MenuItem onClick={this.handleClick} data={{item: "item 1"}}>
            <i className="material-icons">account_circle</i>
            Menu Item 1
            <i className="material-icons">all_out</i></MenuItem>
        <MenuItem onClick={this.handleClick} data={{item: "item 2"}}>Menu Item 2</MenuItem>
        <SubMenu title="A SubMenu">
            <span>ASubMenu</span>
            <i className="material-icons">alarm_add</i>
            <MenuItem onClick={this.handleClick} data={{item: "subitem 1"}}>SubItem 1</MenuItem>
            <SubMenu title="Another SubMenu">
                <i className="material-icons">all_out</i>
                <MenuItem onClick={this.handleClick} data={{item: "subsubitem 1"}}>SubSubItem 1</MenuItem>
                <MenuItem onClick={this.handleClick} data={{item: "subsubitem 2"}}>SubSubItem 2</MenuItem>
            </SubMenu>
            <SubMenu title="Yet Another SubMenu">
                <MenuItem onClick={this.handleClick} data={{item: "subsubitem 3"}}>SubSubItem 3</MenuItem>
                <MenuItem onClick={this.handleClick} data={{item: "subsubitem 4"}}>SubSubItem 4</MenuItem>
            </SubMenu>
            <i className="material-icons">alarm_add</i>
            <MenuItem onClick={this.handleClick} data={{item: "subitem 2"}}>SubItem 2</MenuItem>
        </SubMenu>
    </ContextMenu>
    
</div>
onClick(click-event,data,srcElement)
 
srcElement come from rightClick

I have no idea of reusing Menus.

you can create one ContextMenu,then use jquery to bind events to TreeElement manually.

create too much Menus will slow browser, but pass args easier.

like this:

 see example:
    $(".tree").bind("contextmenu",function(event){
         getElementById(ContextMenuID).dispatchEvent("contextmenu",event,$(this));
    };
    
        $(".gg").bind("contextmenu",function(event){
            event.stopPropagation();
            event.preventDefault();
            var evt = document.createEvent( 'HTMLEvents' );
            evt.initEvent("contextmenu", true, true);
            document.getElementById("mainContextMenu").dispatchEvent(evt,"contextmenu");
            console.log("bindding");
        });

react-contextmenu's People

Contributors

vkbansal avatar bjarkig82 avatar f1qwase avatar meikoudras avatar biggihs avatar tegmos avatar jesenko avatar vnguyen-ombud avatar willgates avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.