# react-drag-drawer

> Draggable react drawer

Latest version **3.3.4** (published 2020-06-07) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.3.4 |
| Published | 2020-06-07 |
| First published | 2017-05-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 1.4 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 165 |
| Maintainers | hanford |
| Keywords | react, react-component, drawer, draggable |

## Links

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

## Dependencies (6)

- [global](https://npm.io/package/global.md) ~4.3.2
- [emotion](https://npm.io/package/emotion.md) ~9.1.2
- [prop-types](https://npm.io/package/prop-types.md) ~15.6.1
- [react-motion](https://npm.io/package/react-motion.md) ~0.5.2
- [intersection-observer](https://npm.io/package/intersection-observer.md) ~0.5.0
- [react-intersection-observer](https://npm.io/package/react-intersection-observer.md) ~3.0.3

## 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.3.4 (latest) — 2020-06-07
- 2.1.1-17 (beta) — 2018-04-25
- 3.3.3 — 2019-11-12
- 3.3.2 — 2019-11-08
- 3.3.1 — 2019-06-21
- 3.3.0 — 2018-10-01
- 3.2.0 — 2018-04-30
- 3.1.2 — 2018-04-30
- 3.1.1 — 2018-04-30
- 3.0.1 — 2018-04-30
- 3.0.0 — 2018-04-26
- 2.1.1-16 — 2018-04-25
- 2.1.1-15 — 2018-04-24
- 2.1.1-14 — 2018-04-24
- 2.1.1-13 — 2018-04-24
- … 75 more at https://npm.io/package/react-drag-drawer/versions

## README

## react-drag-drawer

[![npm package][npm-badge]][npm]

> Mobile draggable drawer that falls back to modals on desktop

[npm-badge]: https://img.shields.io/npm/v/react-drag-drawer.png?style=flat-square
[npm]: https://www.npmjs.org/package/react-drag-drawer

[Live demo!](https://react-drag-drawer.now.sh)

## Install

```
$ npm install react-drag-drawer --save
```

## Usage

```js
import Drawer from 'react-drag-drawer'

..

toggle = () => {
  let { toggle } = this.state

  this.setState({ toggle: !toggle })
}

render () {
  const { open } = this.state

  return (
    <Drawer
      open={open}
      onRequestClose={this.toggle}
    >
      <div>Hey Im inside the drawer!</div>
    </Drawer>
  )
}
```

![](http://d.pr/i/ThqP+)

## API

| Param                 | Type     | functionality                                               | required |
| --------------------- | -------- | ----------------------------------------------------------- | -------- |
| open                  | Boolean  | null                                                        | true     |
| children              | Node     | null                                                        | true     |
| onRequestClose        | Function | null                                                        | true     |
| onDrag                | Function | invoked on drag                                             | false    |
| onOpen                | Function | invoked on drawer focus                                     | false    |
| notifyWillClose       | Function | notify consumer if the drawer will close at touch release   | false    |
| allowClose            | Boolean  | block closing if allowClose={false}, default is true        | false    |
| modalElementClass     | String   | className to be applied to top <Drawer> element             | false    |
| containerElementClass | String   | className to be applied to the drawer container element     | false    |
| parentElement         | ref      | block scrolls on element if you're not using body scrolling | false    |
| direction             | String   | direction to translate drawer                               | false    |
| dontApplyListeners    | Boolean  | skip applying internal event listeners to the dom           | false    |
| inViewportChange      | Function | detect when drawer is at top of viewport                    | false    |
| getModalRef           | Function | get modal (draggable element) ref                           | false    |
| getContainerRef       | Function | get container (overlay) ref                                 | false    |

Example modal style

```css
.modal {
  outline: none;
  background: white;
  font-size: 1.6rem;
  width: 76rem;
  max-width: 90%;
  display: flex;
  justify-content: space-between;
  flex-direction: column;
  z-index: 15;
  min-height: 47rem;

  will-change: transform;
  transform: translate3d(0, 0, 0);
}

@media (max-width: 768px) {
  .modal {
    width: 100%;
    max-width: 100%;
    margin-bottom: 0;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
  }
}
```

## License

MIT © [Jack Hanford](http://jackhanford.com)

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