3.1.4 • Published 4 years ago

react-motion-drawer-alt v3.1.4

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Example | Usage | API | Changelog

Navigation drawer built with the awesome react-motion by @chenglou and react-hammerjs by @JedWatson

npm version

Example

A live demo is available here!

To run the example locally, run:

$ yarn
$ yarn serve

Installation

Via npm:

npm install react-motion-drawer

Usage

import Drawer from 'react-motion-drawer';
  <Drawer open={false} onChange={onChange}>
    <ul>
      <li>Home</li>
      <li>About</li>
      <li>Settings</li>
    </ul>
  </Drawer>

If you want the drawer on the right side of the screen you need the following css.

  body {
    overflow: hidden;
  }

Hooking into the animation

You can hook into the animation by passing a function as the child component.

  <Drawer open={false} width={300} onChange={onChange}>
    { val =>
      <ul style={{ opacity: 300 / val }}>
        <li>Home</li>
        <li>About</li>
        <li>Settings</li>
      </ul>
    }
  </Drawer>

API

Props

Prop Nametypedefaultdescription
zIndexnumber10000z-index of the drawer
noTouchOpenboolfalsecan a user pan to open
noTouchCloseboolfalsecan a user pan to close
onChangefunc() => {}called when the drawer is open
drawerStyleobjectnulladditional drawer styles
classNameobjectnulladditional drawer className
overlayClassNameobjectnulladditional overlay className
configobjectnullconfiguration of the react-motion animation
openboolfalsestates if the drawer is open
widthnumber300width of the drawer
heightnumber100%height of the drawer
handleWidthnumber20width of the handle
peakingWidthnumber50width that the drawer peaks on press
panTolerancenumber50tolerance until the drawer starts to move
rightboolfalsedrawer on the right side of the screen
overlayColorstring'rgba(0, 0, 0, 0.4)'color of the overlay
fadeOutboolfalsefade out
offsetnumber0offset of the drawer

License

MIT © Christoph Hermann