• Stars
    star
    160
  • Rank 234,703 (Top 5 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 9 years ago
  • Updated about 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A React mixin version of Amazon's jQuery-menu-aim plugin

ReactMenuAim

A React Mixin makes your menu works as magical as Amazon's implementation, this repo is heavily inspired by jQuery-menu-aim.

中文说明

Build Status npm version

ReactMenuAim demo

If you tend to support React v0.13, please use [email protected] which is the latest compatible version.

How to use

Live Demo

You can also checkout ./demo folder find out the simple & stragiht demo usage, or here's a quick look.

var React = require('react');
var ReactMenuAim = require('react-menu-aim');

var Menu = React.createClass({
  mixins: [ReactMenuAim],

  componentWillMount: function() {
    // Config ReactMenuAim here
    this.initMenuAim({
      submenuDirection: 'right',
      menuSelector: '.menu'
    });
  },

  // This is your true handler when a menu item is going to be active
  handleSwitchMenuIndex: function(index) {
    // ...
  },

  // `this.handleMouseLeaveMenu` and `this.handleMouseEnterRow` are provided by ReactMenuAim,
  // you can provide your own handler bound to them
  render: function() {
    return (
      <div className="menu-container">
        <ul className="menu" onMouseLeave={this.handleMouseLeaveMenu}>
          <li className="menu-item" onMouseEnter={this.handleMouseEnterRow.bind(this, 0, this.handleSwitchMenuIndex)}>Menu Item 1</li>
          <li className="menu-item" onMouseEnter={this.handleMouseEnterRow.bind(this, 1, this.handleSwitchMenuIndex)}>Menu Item 2</li>
        </ul>
      </div>
    );
  }
});

Event handler

The following event handlers are provided by ReactMenuAim.

DO NOT call them directly, pass them as event handler in component's render method.

handleMouseLeaveMenu

This event handler should be called when mouse is leaving the menu.

Arguments

  1. handler (Function) You can provide your own handler when mouse leave menu
  2. e (Object) React's synthetic event

handleMouseEnterRow

This event handler should be called when mouse is entering a menu item.

Arguments

  1. rowIdentifier (Any) The identifier you provided to identify a row, usually it's row index or something, will be passed to your handler when a menu is going to be activated.
  2. handler (Function) You can provide your own handler when mouse enter a row
  3. e (Object) React's synthetic event

Configuration

To configure ReactMenuAim, you should call this.initMenuAim in your React component with your options.

  componentWillMount: function() {
    this.initMenuAim({
      // options
    });
  }

submenuDirection

Type: string Default: 'right'

Indicates the direction of submenu.

menuSelector

Type: string Default: '*'

Determine the position and offset of menu container. This selector should be constrained on the very exact menu area(which we are switching), not including submenu area.

delay

Type: number Default: 300

When user is moving mouse and have a tendency of viewing submenu, how many ms to wait before making next move.

tolerance

Type: number Default: 75

The larger, the submenu is more likely to show.

Scripts

$ npm install
$ npm run test
$ npm run build
$ npm run watch

License

MIT

More Repositories

1

a-cartoon-intro-to-redux-cn

看漫画,学 Redux。不写一行代码,轻松看懂 Redux 原理!
HTML
768
star
2

react-anything-sortable

A ReactJS component that can sort any children with touch support and IE8 compatibility
JavaScript
459
star
3

redux-sequence-action

Dispatch your action one by one with previously updated store
JavaScript
101
star
4

react-marquee

A <marquee> component for React
JavaScript
81
star
5

redux-form-utils

Ease the pain of handling form bindings in Redux
JavaScript
73
star
6

china-city-select

简单可用的中国省份、城市、县区三级联动选择组件
JavaScript
60
star
7

react-lifecycle

A ReactJS mixin for logging component lifecycle method call
JavaScript
54
star
8

redux-composable-fetch

A fetch middleware with extensible and opt-in functionalities like cache or log for Redux
JavaScript
37
star
9

react-redux-async-example

A react, redux, ajax working example
JavaScript
33
star
10

bjut_crawler

BJUT secrets~
JavaScript
32
star
11

alarm

A simple & super fast & responsive Ghost theme
CSS
31
star
12

undefinedblog

我的个人博客(源码)
CSS
23
star
13

test-react

JavaScript
8
star
14

hexo-migrator-ghost

Ghost migrator for Hexo.
JavaScript
7
star
15

healthreport

A toy app to analyze health report and ask questions
JavaScript
5
star
16

In-page-Highlighter

Instantly highlight anything you select in current page (Chrome plug-in)
JavaScript
4
star
17

gulp-legacy-ie-css-lint

Ensure your CSS won't be discarded by IE 9 and below because of crazy stylesheets limitation of legacy IE.
JavaScript
3
star
18

grunt-wordpress

Simple & working Grunt configuration set for Wordpress development
JavaScript
3
star
19

easy-js-perf

A human readable wrapper of `window.performance` API
JavaScript
2
star
20

ultimate-gitlab-gitbook

Receive Gitlab web hook, generate content using Gitbook, enhance search functionality using ElasticSearch.
JavaScript
2
star
21

Ali_learning

JavaScript
2
star
22

webpack-debug-plugin

Inject useful debug info to each entry in the runtime
JavaScript
2
star
23

jsbin-nude

JS Bin with NO Backend Dependency
JavaScript
1
star
24

react-analyzer

Give you a human readable structure of your React component
JavaScript
1
star
25

canon-blog

Blog for canon
PHP
1
star
26

ceresdb

A simple node.js client for CeresDB
TypeScript
1
star
27

excel-gantt-chart

Automatically exported from code.google.com/p/excel-gantt-chart
1
star
28

jasonslyvia.github.io

1
star
29

grunt-wp-replace

Replace new static assets reference(js or css) in Wordpress theme source file
JavaScript
1
star
30

canon

Just another WordPress theme.
JavaScript
1
star