# react-motion-drawer

> Navigation drawer built with the awesome react-motion and react-hammerjs

Latest version **3.1.0** (published 2018-04-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-motion-drawer
pnpm add react-motion-drawer
yarn add react-motion-drawer
bun add react-motion-drawer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2018-04-02 |
| First published | 2015-09-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 20 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 219 |
| Author | Christoph Hermann |
| Maintainers | jamuhl, kylemathews, redmega, schtoeffel |
| Keywords | react, reactjs, react-motion, react-hammerjs, touch, drawer, navigation |

## Links

- npm: https://www.npmjs.com/package/react-motion-drawer
- Repository: https://github.com/stoeffel/react-motion-drawer
- Issues: https://github.com/stoeffel/react-motion-drawer/issues
- npm.io page: https://npm.io/package/react-motion-drawer

## Dependencies (4)

- [1-liners](https://npm.io/package/1-liners.md) ^0.4.0
- [prop-types](https://npm.io/package/prop-types.md) ^15.5.10
- [react-motion](https://npm.io/package/react-motion.md) ^0.5.2
- [react-hammerjs](https://npm.io/package/react-hammerjs.md) ^1.0.1

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 3.1.0 (latest) — 2018-04-02
- 3.0.4 — 2018-03-27
- 3.0.3 — 2018-03-27
- 3.0.2 — 2018-03-27
- 3.0.1 — 2018-03-27
- 2.1.7 — 2017-10-25
- 2.1.6 — 2017-10-24
- 2.1.5 — 2017-02-28
- 2.1.4 — 2017-02-27
- 2.1.3 — 2017-02-27
- 2.1.2 — 2017-02-07
- 3.0.0 — 2015-10-22
- 2.1.0 — 2015-10-05
- 2.0.1 — 2015-10-05
- 2.0.0 — 2015-10-02
- … 11 more at https://npm.io/package/react-motion-drawer/versions

## README

<h1 align="center">react-motion-drawer</h1>

<p align="center">

  <a href="#example">Example</a> |
  <a href="#usage">Usage</a> |
  <a href="#api">API</a> |
  <a href="CHANGELOG.md">Changelog</a>
  <br><br>
  <img  align="center" src="./media/drawer.gif">
</p>

> Navigation drawer built with the awesome [react-motion][rm] by [@chenglou][c] and [react-hammerjs][rh] by [@JedWatson][j]

[![npm version](https://badge.fury.io/js/react-motion-drawer.svg)](https://badge.fury.io/js/react-motion-drawer)

## Example

A live demo is available [here](https://react-motion-drawer.netlify.com/)!

To run the example locally, run:
```bash
$ yarn
$ yarn serve
```

## Installation

Via npm:
```
npm install react-motion-drawer
```

## Usage

```js
import Drawer from 'react-motion-drawer';
```

```jsx
  <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.

```css
  body {
    overflow: hidden;
  }
```

### Hooking into the animation

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

```jsx
  <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

* `zIndex: number`           - z-index of the drawer (default `10000`)
* `noTouchOpen: bool`        - can a user pan to open (default `false`)
* `noTouchClose: bool`       - can a user pan to close(default `false`)
* `onChange: func`           - called when the drawer is open (default `() => {}`)
* `drawerStyle: object`      - additional drawer styles
* `className: object`        - additional drawer className
* `overlayClassName: object` - additional overlay className
* `config: object`           - configuration of the react-motion animation (default `{stiffness: 350, damping: 40}`)
* `open: bool`               - states if the drawer is open (default `false`)
* `width: number`            - width of the drawer (default `300`)
* `height: number`           - height of the drawer (default `'100%'`)
* `handleWidth: number`      - width of the handle (default `20`)
* `peakingWidth: number`     - width that the drawer peaks on press (default `50`)
* `panTolerance: number`     - tolerance until the drawer starts to move (default `50`)
* `right: bool`              - drawer on the right side of the screen (default `false`)
* `overlayColor: string`     - color of the overlay (default `rgba(0, 0, 0, 0.4)`)
* `fadeOut: bool`            - fade out (default `false`)
* `offset: number`           - offset of the drawer (default `0`)

## License

MIT © [Christoph Hermann](http://stoeffel.github.io)

[rm]: https://github.com/chenglou/react-motion
[rh]: https://github.com/JedWatson/react-hammerjs
[c]: https://github.com/chenglou
[j]: https://github.com/JedWatson

---
_Source: https://npm.io/package/react-motion-drawer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
