GithubHelp home page GithubHelp logo

negomi / react-burger-menu Goto Github PK

View Code? Open in Web Editor NEW
5.0K 5.0K 584.0 8.82 MB

:hamburger: An off-canvas sidebar component with a collection of effects and styles using CSS transitions and SVG path animations

Home Page: http://negomi.github.io/react-burger-menu/

License: MIT License

JavaScript 95.71% HTML 0.53% Less 3.76%
animations component hamburger-menu react sidebar transitions

react-burger-menu's Introduction

react-burger-menu Build Status code style: prettier

An off-canvas sidebar React component with a collection of effects and styles using CSS transitions and SVG path animations.

Using Redux? Check out redux-burger-menu for easy integration of react-burger-menu into your project.

Demo & examples

Live demo: negomi.github.io/react-burger-menu

To build the examples locally, first make sure you're using Node <11.0.0. Then run:

npm install
npm start

Then open localhost:8000 in a browser.

Tests

The test suite uses Mocha, Chai and Sinon, with jsdom.

To run the tests once, run:

npm test

To run them with a watcher, run:

npm run test:watch

Installation

The easiest way to use react-burger-menu is to install it from npm and include it in your own React build process (using Browserify, Webpack, etc).

You can also use the standalone build by including dist/react-burger-menu.js in your page. If you use this, make sure you have already included React, and it is available as a global variable.

Version 3.x uses Hooks, so if you're using React 16.8+:

npm install react-burger-menu --save

If you're using an earlier version of React:

npm install react-burger-menu@^2.9.2 --save

Usage

Items for the sidebar should be passed as child elements of the component using JSX.

import { slide as Menu } from 'react-burger-menu'

class Example extends React.Component {
  showSettings (event) {
    event.preventDefault();
    .
    .
    .
  }

  render () {
    // NOTE: You also need to provide styles, see https://github.com/negomi/react-burger-menu#styling
    return (
      <Menu>
        <a id="home" className="menu-item" href="/">Home</a>
        <a id="about" className="menu-item" href="/about">About</a>
        <a id="contact" className="menu-item" href="/contact">Contact</a>
        <a onClick={ this.showSettings } className="menu-item--small" href="">Settings</a>
      </Menu>
    );
  }
}

Animations

The example above imported slide which renders a menu that slides in on the page when the burger icon is clicked. To use a different animation you can substitute slide with any of the following (check out the demo to see the animations in action):

  • slide
  • stack
  • elastic
  • bubble
  • push
  • pushRotate
  • scaleDown
  • scaleRotate
  • fallDown
  • reveal

Properties

Some animations require certain other elements to be on your page:

  • Page wrapper - an element wrapping the rest of the content on your page (except elements with fixed positioning - see the wiki for details), placed after the menu component

    <Menu pageWrapId={ "page-wrap" } />
    <main id="page-wrap">
      .
      .
      .
    </main>
  • Outer container - an element containing everything, including the menu component

    <div id="outer-container">
      <Menu pageWrapId={ "page-wrap" } outerContainerId={ "outer-container" } />
      <main id="page-wrap">
        .
        .
        .
      </main>
    </div>

If you are using an animation that requires either/both of these elements, you need to give the element an ID, and pass that ID to the menu component as the pageWrapId and outerContainerId props respectively.

Check this table to see which animations require these elements:

Animation pageWrapId outerContainerId
slide
stack
elastic
bubble
push
pushRotate
scaleDown
scaleRotate
fallDown
reveal

Position

The menu opens from the left by default. To have it open from the right, use the right prop. It's just a boolean so you don't need to specify a value. Then set the position of the button using CSS.

<Menu right />

Width

You can specify the width of the menu with the width prop. The default is 300.

<Menu width={ 280 } />
<Menu width={ '280px' } />
<Menu width={ '20%' } />

Open state

You can control whether the sidebar is open or closed with the isOpen prop. This is useful if you need to close the menu after a user clicks on an item in it, for example, or if you want to open the menu from some other button in addition to the standard burger icon. The default value is false.

// To render the menu open
<Menu isOpen />
<Menu isOpen={ true } />

// To render the menu closed
<Menu isOpen={ false } />

You can see a more detailed example of how to use isOpen here.

Note: If you want to render the menu open initially, you will need to set this property in your parent component's componentDidMount() function.

Open menu handler

If you keep the menu state yourself it might be convenient to pass a custom function to be used when the user triggers something that should open the menu.

Called when:

  • The user clicks on the burger icon
<Menu onOpen={ handleOnOpen } />

Note: The menu will NOT open automatically if you pass this prop, so you must handle it yourself.

Close menu handler

If you keep the menu state yourself it might be convenient to pass a custom function to be used when the user triggers something that should close the menu.

Called when:

  • The user clicks on the cross icon
  • The user clicks on the overlay
  • The user hits the escape key
<Menu onClose={ handleOnClose } />

Note: The menu will NOT close automatically if you pass this prop, so you must handle it yourself.

State change

You can detect whether the sidebar is open or closed by passing a callback function to onStateChange. The callback will receive an object containing the new state as its first argument.

var isMenuOpen = function(state) {
  return state.isOpen;
};

<Menu onStateChange={ isMenuOpen } />

Close on Escape

By default, the menu will close when the Escape key is pressed. To disable this behavior, you can pass the disableCloseOnEsc prop. This is useful in cases where you want the menu to be open all the time, for example if you're implementing a responsive menu that behaves differently depending on the browser width.

<Menu disableCloseOnEsc />

Custom keydown handler

For more control over global keypress functionality, you can override the handler that this component sets for window.addEventListener('keydown', handler), and pass a custom function. This could be useful if you are using multiple instances of this component, for example, and want to implement functionality to ensure that a single press of the Escape key closes them all.

const closeAllMenusOnEsc = (e) => {
  e = e || window.event;

  if (e.key === 'Escape' || e.keyCode === 27) {
    this.setState({areMenusOpen: false});
  }
};

<MenuOne customOnKeyDown={closeAllMenusOnEsc} isOpen={areMenusOpen} />
<MenuTwo customOnKeyDown={closeAllMenusOnEsc} isOpen={areMenusOpen} />

Note: Using this prop will disable all the default 'close on Escape' functionality, so you will need to handle this (including determining which key was pressed) yourself.

Overlay

You can turn off the default overlay with noOverlay.

<Menu noOverlay />

You can disable the overlay click event (i.e. prevent overlay clicks from closing the menu) with disableOverlayClick. This can either be a boolean, or a function that returns a boolean.

<Menu disableOverlayClick />
<Menu disableOverlayClick={() => shouldDisableOverlayClick()} />

Transitions

You can disable all transitions/animations by passing noTransition.

<Menu noTransition />

This is useful if you want the menu to remain open across re-mounts, for example during SPA route changes.

Custom icons

You can replace the default bars that make up the burger and cross icons with custom ReactElements. Pass them as the customBurgerIcon and customCrossIcon props respectively.

<Menu customBurgerIcon={ <img src="img/icon.svg" /> } />
<Menu customCrossIcon={ <img src="img/cross.svg" /> } />

You should adjust their size using the .bm-burger-button and .bm-cross-button classes, but the element itself will have the class .bm-icon or .bm-cross if you need to access it directly.

You can also disable the icon elements so they won't be included at all, by passing false to these props.

<Menu customBurgerIcon={ false } />
<Menu customCrossIcon={ false } />

This can be useful if you want exclusive external control of the menu, using the isOpen prop.

Custom ID and/or classNames

There are optional id and className props, which will simply add an ID or custom className to the rendered menu's outermost element. This is not required for any functionality, but could be useful for things like styling with CSS modules.

<Menu id={ "sidebar" } className={ "my-menu" } />

You can also pass custom classNames to the other elements:

<Menu burgerButtonClassName={ "my-class" } />
<Menu burgerBarClassName={ "my-class" } />
<Menu crossButtonClassName={ "my-class" } />
<Menu crossClassName={ "my-class" } />
<Menu menuClassName={ "my-class" } />
<Menu morphShapeClassName={ "my-class" } />
<Menu itemListClassName={ "my-class" } />
<Menu overlayClassName={ "my-class" } />

And to the html and body elements (applied when the menu is open):

<Menu htmlClassName={ "my-class" } />
<Menu bodyClassName={ "my-class" } />

Note: Passing these props will prevent the menu from applying styles to the html or body elements automatically. See here for more explanation.

Focusing the first menu item

By default, the menu will set focus on the first item when opened. This is to help with keyboard navigation. If you don't want this functionality, you can pass the disableAutoFocus prop.

<Menu disableAutoFocus />

Custom item list element

The menu's children are all wrapped in a nav element by default, as navigation is likely the most common use case for this component. However, it's a general purpose sidebar, so you can change this to a div if you're not using it for navigation:

<Menu itemListElement="div" />

Styling

All the animations are handled internally by the component. However, the visual styles (colors, fonts etc.) are not, and need to be supplied, either with CSS or with a JavaScript object passed as the styles prop.

CSS

The component has the following helper classes:

/* Position and sizing of burger button */
.bm-burger-button {
  position: fixed;
  width: 36px;
  height: 30px;
  left: 36px;
  top: 36px;
}

/* Color/shape of burger icon bars */
.bm-burger-bars {
  background: #373a47;
}

/* Color/shape of burger icon bars on hover*/
.bm-burger-bars-hover {
  background: #a90000;
}

/* Position and sizing of clickable cross button */
.bm-cross-button {
  height: 24px;
  width: 24px;
}

/* Color/shape of close button cross */
.bm-cross {
  background: #bdc3c7;
}

/*
Sidebar wrapper styles
Note: Beware of modifying this element as it can break the animations - you should not need to touch it in most cases
*/
.bm-menu-wrap {
  position: fixed;
  height: 100%;
}

/* General sidebar styles */
.bm-menu {
  background: #373a47;
  padding: 2.5em 1.5em 0;
  font-size: 1.15em;
}

/* Morph shape necessary with bubble or elastic */
.bm-morph-shape {
  fill: #373a47;
}

/* Wrapper for item list */
.bm-item-list {
  color: #b8b7ad;
  padding: 0.8em;
}

/* Individual item */
.bm-item {
  display: inline-block;
}

/* Styling of overlay */
.bm-overlay {
  background: rgba(0, 0, 0, 0.3);
}

JavaScript

The same styles can be written as a JavaScript object like this:

var styles = {
  bmBurgerButton: {
    position: 'fixed',
    width: '36px',
    height: '30px',
    left: '36px',
    top: '36px'
  },
  bmBurgerBars: {
    background: '#373a47'
  },
  bmBurgerBarsHover: {
    background: '#a90000'
  },
  bmCrossButton: {
    height: '24px',
    width: '24px'
  },
  bmCross: {
    background: '#bdc3c7'
  },
  bmMenuWrap: {
    position: 'fixed',
    height: '100%'
  },
  bmMenu: {
    background: '#373a47',
    padding: '2.5em 1.5em 0',
    fontSize: '1.15em'
  },
  bmMorphShape: {
    fill: '#373a47'
  },
  bmItemList: {
    color: '#b8b7ad',
    padding: '0.8em'
  },
  bmItem: {
    display: 'inline-block'
  },
  bmOverlay: {
    background: 'rgba(0, 0, 0, 0.3)'
  }
}

<Menu styles={ styles } />

Browser support

Because this project uses CSS3 features, it's only meant for modern browsers. Some browsers currently fail to apply some of the animations correctly.

Chrome and Firefox have full support, but Safari and IE have strange behavior for some of the menus.

Help

Check the FAQ (https://github.com/negomi/react-burger-menu/wiki/FAQ) to see if your question has been answered already, or open a new issue.

License

MIT

react-burger-menu's People

Contributors

a-type avatar andrewmartin avatar badtant avatar bkozlowwaverley avatar calvinwyoung avatar chukwuemeka avatar codeheroics avatar costagolub avatar dependabot[bot] avatar dirtyredz avatar fabb avatar gumberss avatar ignatiusreza avatar ivan-aksamentov avatar jackhedaya avatar jamesthehacker avatar jb1361 avatar jorrit avatar kimyu92 avatar lunnatica avatar melanieseltzer avatar mxs avatar negomi avatar patrik-piskay avatar pedrogustavo avatar rafipiccolo avatar rahavlussato avatar richardxia avatar rivertam avatar spencerbeggs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-burger-menu's Issues

Allow for font icon

For instance, we want to use Ionicons, so it would be great if react-burger-menu supported them. Example usage for ionicons:

<span class="ion-android-arrow-back"></span>

This could be similar to accepting an image for the close button:

<Menu customCloseFont="ion-android-arrow-back">

So then, if it's set, those classes are added to a simple <span> or <i>. This would make it also compatible with other fonts like Bootstrap's font-awesome:

<Menu customCloseFont="glyphicon glyphicon-remove">

Or fontello:

<Menu customCloseFont="icon-close">

React 15 - remove peerDependencies

Hey, would you mind removing peerDependencies so we can choose the appropriate react version ourselves? Many libraries turned their backs to peerDependencies now.

Multiple .js files in the example index.html

Hi and Thanks for this awesome project,
The example includes example.js and common.js as well as bundle.js,
All the other components I've included in my webpack app so far have all been packed into a single bundle.js file?

Perspective in Chrome

Thanks for the menu, very nice!

I am using it in a small app and I noticed that when using e.g. scale down, the content/fonts look different after using the menu (also happens on http://negomi.github.io/react-burger-menu/ ) I think, if you look closely.

I am no expert on CSS Transform, but it seems to me that setting perspective to 1500px and leaving it so after closing the menu is the problem.

(many stackoverflow threads around this topic, e.g. http://stackoverflow.com/questions/6411361/webkit-based-blurry-distorted-text-post-animation-via-translate3d)

I quickly tried to fix things using

outerContainer: function outerContainer(isOpen) {
        return {
      perspective: isOpen ? '' : '1500px',
    };
  }

in https://github.com/negomi/react-burger-menu/blob/master/src/menus/scaleDown.js#L16-L20

This seems to reset perspective after the menu closes (and I get clear fonts again), but the animation is broken, on close, as there is no end point anymore.

Can you reproduce the problem? Do you have any idea how to solve it?

Server side rendering inconsistent with client side rendering

Just tested server side rendering after you closed #8. First of all, it works, which is really great! Unfortunately the rendering is not consistent between server and client:

Warning: React attempted to reuse markup in a container but the checksum was invalid. 
This generally means that you are using server rendering and the markup generated on 
the server was not what the client was expecting. 
React injected new markup to compensate which works but you have lost many of the 
benefits of server rendering. Instead, figure out why the markup being generated is 
different on the client or server:

Vendor prefixes seem to be the problem.
Chrome:

(client) :rgba(0, 0, 0, 0.3);-webkit-opacity:0;-w
(server) :rgba(0, 0, 0, 0.3);opacity:0;transform:

Firefox:

 (client) , 0, 0.3);opacity:0;-moz-transform:trans
 (server) , 0, 0.3);opacity:0;transform:translate3

Standalone build is not usable

I'm trying the standalone build located at the dist folder but an error is popping up claming that the 'react' module cannot be found.

BTW, I was able to use the standalone version of the v1.1.6 tag after applying this patch. Actually, that's the version I'm interested in because it supports React 0.13.[**]

Back to master... the javascript console shows the following exception:

Uncaught Error: Cannot find module 'react'
s                                 @ react-burger-menu.js:1
(anonymous function)              @ react-burger-menu.js:1
(anonymous function)              @ react-burger-menu.js:1349
21../print-styles.js              @ react-burger-menu.js:1508
s                                 @ react-burger-menu.js:1
(anonymous function)              @ react-burger-menu.js:1
24../components/print-style-sheet @ react-burger-menu.js:1549
s                                 @ react-burger-menu.js:1
(anonymous function)              @ react-burger-menu.js:1
(anonymous function)              @ react-burger-menu.js:2853
41../BurgerIcon                   @ react-burger-menu.js:3037
s                                 @ react-burger-menu.js:1
(anonymous function)              @ react-burger-menu.js:1
49.../menuFactory                 @ react-burger-menu.js:3304
s                                 @ react-burger-menu.js:1
(anonymous function)              @ react-burger-menu.js:1
38../menus/bubble                 @ react-burger-menu.js:2732
s                                 @ react-burger-menu.js:1
e                                 @ react-burger-menu.js:1
(anonymous function)              @ react-burger-menu.js:1
(anonymous function)              @ react-burger-menu.js:1
(anonymous function)              @ react-burger-menu.js:1

The code I'm using can be found here.

I'm not very familiar with package managers for the web and all the require stuff so I cannot make sense of what's going on.

My (little) understanding is that the browserify-shim should make the standalone version use the React symbol in the global scope instead of relying on require. At least that's how it worked for Snap.svg in v1.1.6.

Can you spot anything wrong?


[**] Actually, what I'm trying to do is to package this React component for ClojureScript, so a standalone version is what I need. And due to Om (the CLJS React wrapper) using React 0.13, I guess I'm stuck with version 1.1.6

Question: Close Menu on Link Click

This might be a dumb question, but how do you close the menu when you click a link?

Here's my example:

`


<Link to="/" className={classNameCreative} onClick={ this.toggleMenu }>Creative
People
Engineering
Advertising
Blog

`

The links are navigating to the next view correctly, but the menu stays open. I'm getting the following exception:

Unhandled promise rejection TypeError: Cannot read property 'toggleMenu' of undefined(…)

Customize transition-duration?

I'd like this and will submit a PR if it's welcome.

I'm forcing a 250ms slide transition using !important in css at the moment but it would be nice to have this as a prop.

Horizontal placement options

What about adding horizontal placement? Not sure anyone needs that except me but have something going here (amongst other stuff) if you want to check it out. WIP. See issues. :)

Close 'X' button not working in mobile

When I try to click the close 'X' button on any mobile device it doesn't register. Clicking on the main body of the page does close it. The 'X' does work on desktop. Any reason why this may be happening?

Custom icons, and overlay menu.

Hi @negomi, this plugin looks great! For my particular use-case, I was hoping to support the following features and was wondering if the plugin supports it, plans to support it or how hard would it be for me to fork it to add the functionality -

  1. Custom burger menu icon. More specifically, I was also looking to to add the word 'menu' next to the icon.
  2. An overlay instead of the side bar. Or would it be possible to instead pass in a modal component as a child of the Menu and it would render the modal?

An example implementation for both of those can be seen here - http://teehanlax.com/

Thanks again for the plugin!

Cannot find module 'react-burger-menu' from...

I've installed this module:
npm install react-burger-menu --save

When I try building my project after requiring it, I get:
Cannot find module 'react-burger-menu' from....[location]

I can install other modules and require them just fine - it's only this one which breaks the build process. Any ideas?

Thanks

Missing dependency

Add "imports-loader" module in your dependencies.
My code just broke in production without any obvious error.

tests failing

I'm seeing the tests have a config issue:

Error: Cannot find module 'babel/register'

Thx!

icons only closed Enhancement

Hi Imogen,

It would be nice if there was an option to "close" the (left) menu in such a way that the icons still show and are clickable. I.e. it doesn't completely close / hide.

Thanks! Mark

Unable to run examples

The stack trace is below:

dkulichkin@dkulichkin-B85M-HD3 ~/Projects/react-burger-menu $ gulp dev
[11:40:20] Using gulpfile ~/Projects/react-burger-menu/gulpfile.js
[11:40:20] Starting 'dev:server'...
[11:40:20] Finished 'dev:server' after 8.5 ms
[11:40:20] Starting 'build:example:files'...
[11:40:20] Starting 'build:example:css'...
[11:40:20] Server started http://localhost:8000
[11:40:20] LiveReload started on port 35729
[11:40:20] Finished 'build:example:css' after 70 ms
[11:40:20] Finished 'build:example:files' after 93 ms
[11:40:20] Starting 'watch:examples'...
[11:40:20] Finished 'watch:examples' after 60 ms
[11:40:20] Starting 'dev'...
[11:40:20] Finished 'dev' after 2.78 μs
[11:40:20] example.js built in 0.31s
[11:40:21] bundle.js built in 1.43s
[11:40:21] Browserify Error { [Error: Cannot find module 'react-kit' from '/home/dkulichkin/Projects/react-burger-menu']

Also for some reason is not resolvable by the webpack when including...

Thanks

Server Side Rendering Support on v1.6

Hello,
I am facing issue for server side rendering using react-burger-menu version 1.6.
Here's the warning:
warning.js?0260:45 Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server: (client) ition:opacity 0.3s, transform 0s 0.3s;" (server) ition:opacity 0.3s, -ms-transform 0s 0.3
@negomi

Unable to close menu after clicking on link

I'm using the menu within a "body" component that spans my whole page. I've added the menu as follows and I'm using react router.

var Example = React.createClass({
  showSettings: function(event) {
    event.preventDefault();
  },
  render: function() {
    return (
      <Menu right>
        <RadiumLink className="menu-item" to="/">Home</RadiumLink>
        <RadiumLink className="menu-item" to="/about">About</RadiumLink>
        <RadiumLink className="menu-item" to="/contact">Portfolio</RadiumLink>
        <RadiumLink className="menu-item" to="/contact">Contact</RadiumLink>
      </Menu>
    );
  }
}); 

and this is its parent

render: function() {
        return (
                                <div className="border" ref="frame">
                        <Example />             
                </div>
        );

If I click on a link, it loads the page just fine however, the menu remains open and I have to either use the close button or click outside the menu to close it. How can I get it to auto-close?

Thank you

React Native Support

Does this run on react native? I'm getting odd errors about snap.svg but it still did not work after importing that library

Nav bar?

This is nice! I'd like to use this as the main nav for a hybrid app that must fit both phone and tablet form factors. On the tablet tho, I'd like to have a NavBar on the slide element that is always visible even when the menu is retracted. Any suggestions for best way to handle?

Thanks again, this looks nice :)

imports issue in webpack

When using webpack the component gives the following error:

WARNING in ./~/react-burger-menu/lib/menuFactory.js
Module not found: Error: Cannot resolve module 'imports' in /project/node_modules/react-burger-menu/lib
 @ ./~/react-burger-menu/lib/menuFactory.js 24:9-87

I think it's because of the snap.svg workaround. I think it's because webpack couldn't find that loader in my project so I just had to add imports-loader in my devDependencies and it worked. Not sure if anyone else came across something similar.

Externally control open state.

Thanks for beautiful components, but here my 2 cent, if isOpen props is set on Menu, then it should remove click handle on burger and cross button, and only give two other request function ( (for e.g. onRequestOpen and onRequestClose), otherwise external state would be out-of-sync, right? And what about a props to completely remove burger and cross button (false on customIcon). Thanks, if I find some time, I will make a PR.

Passing isOpen props to the menu doesn't work

i tried passing the isOpen as a props, but the menu doesn't open. i tried debugging and it seems you would want to read the props and update state in the componentWillReceiveProps function?
<Menu styles={menuStyles} isOpen={this.state.isMenuOpen}> <a id="home" className="menu-item" href="/">Home</a> <a id="about" className="menu-item" href="/about">About</a> <a id="contact" className="menu-item" href="/contact">Contact</a> </Menu>

Change side of menu?

Is there an easy way to change the side of the menu? If not my only option really is to fork this repo...

No pageWrapId/outerContainerId supplied

Hi,

Not sure why this is happening but I keep getting a console warning "No pageWrapId supplied" and "No outerContainerId supplied", thus I cannot use the 'push' animation or any of the animations that require those definitions. Any idea why this might be happening?

Here's where I define them:

<div id="outer-container"> <Menu pageWrapId={ "page-wrap" } outerContainerId={ "outer-container" } /> <main id="page-wrap">

Thanks!

React Burger Menu breaks Firefox

I'm not sure why, but with react-burger-menu I get this issue:

TypeError: CSS2Properties doesn't have an indexed property setter for '0'

It breaks my react-router and I'm no longer able to navigate within the app

Link from react-router instead of a

Do you mind updating the documentation on the usage of the Link component from react-router. It's not working out of the box, Link has to be wrapped into Radium:

import React from 'react';
import {stack as Menu} from 'react-burger-menu';
import {Link} from 'react-router';
import Radium from 'radium';

let RadiumLink = Radium(Link);

export default React.createClass({
    render: function() {
        return (
            <Menu>
                <RadiumLink className="menu-item" to="/home">Home</RadiumLink>
                <RadiumLink className="menu-item" to="/settings">Settings</RadiumLink>
                <RadiumLink className="menu-item" to="/blablabla">Blablabla</RadiumLink>
            </Menu>
        );
    }

});

Thanks a lot for this component, very useful.

Error loading Snapsvg using Webpack.

there seems to be some issue with webpack and snapsvg. The error reads Cannot read property 'on' of undefined. I also followed this issue thread for solution: adobe-webplatform/Snap.svg#341

However, I still am not able to get it to work. Any possible solution to replace var Snap = require( "imports-loader?this=>window,fix=>module.exports=0!snapsvg/dist/snap.svg.js" );

Open State

Thanks again for this,

for isOpen, if the default value is false,

is <Menu isOpen /> the same as <Menu isOpen={true}/> and

<Menu /> the same as <Menu isOpen={false}/>

can't get either working for some reason. My current workaround (in an onClick handler for each element) is:

        const clickEvt = new MouseEvent("click", {
            view: window,
            bubbles: true,
            cancelable: true
        });
        var crossButton = document.getElementsByClassName('bm-overlay');
        try {
            crossButton[0].dispatchEvent(clickEvt);
        } catch(err) {}

This closes the menu after an item has been selected.

docs don't say how to open the menu

This plugin looks awesome, but I don't see a straightforward way to connect a button to the menu... and the example is convoluted, not a basic use case...

angular 2 port?

this is by far the most good looking side nav I have ever seen.
would live to get it working over angular 2 when its out...
did you ever think of porting this to multiple frameworks? will it be hard to do?

Webpack Example

Hi there,

I'm hoping you can provide an example of how to integrate this into an existing Webpack setup using import-loaders (as suggested in your readme)?

Menu looks amazing!

Error: Cannot resolve module 'react-burger-menu'

I am trying to install the react-burger-menu in my app via npm and I keep running into this issue whenever I try to include "var Menu = require('react-burger-menu');" in my app, it throw an error of Error: Cannot resolve module 'react-burger-menu'

Push menu closed always shows page-wrapper as opened and vice versa

I am experiencing this weird error with the 'push' menu. 'isOpen' is set based on the state of the menu. When the app is loaded its set to false. The BurgerMenu is hidden, but page-wrapper is shifted to the right as it would be opened.

<BurgerMenu
  width={290}
  pageWrapId={'page-wrapper'}
  outerContainerId={'outer-container'}
  styles={styles}
  onStateChange={this.stateChange.bind(this)}
  isOpen={isOpen}>
    <Menu {...menuProps}/>
</BurgerMenu>

It looks like the isOpen is somehow failing - setting it to false closes the menu, but opens the wrapper and vice versa; setting it to true opens the menu and closes the wrapper.

Responsive menu

A really nice feature of the library would be to integrate responsiveness to the menu. Keep the menu always open after certain screen width and on the other hand close it if the screen width is too small.

Something like this.

[Enhancement] Wave Support

I noticed that the OffCanvasMenuEffects repo has a wave effect. Is it possible to do this now or does this need to be implemented. I really love this component and the effects you currently have!

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.