# use-draggable-scroll

> React hook to add draggability to scrollable content easily

Latest version **0.1.0** (published 2021-06-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install use-draggable-scroll
pnpm add use-draggable-scroll
yarn add use-draggable-scroll
bun add use-draggable-scroll
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2021-06-19 |
| First published | 2021-06-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 24 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 35 |
| Author | Guillermo del Molino |
| Maintainers | g-delmo |
| Keywords | draggable, drag, scroll, react, draggability |

## Links

- npm: https://www.npmjs.com/package/use-draggable-scroll
- Repository: https://github.com/g-delmo/use-draggable-scroll
- Homepage: https://github.com/g-delmo/use-draggable-scroll#readme
- Issues: https://github.com/g-delmo/use-draggable-scroll/issues
- npm.io page: https://npm.io/package/use-draggable-scroll

## 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

- 0.1.0 (latest) — 2021-06-19

## README

# use-draggable-scroll

React hook to add draggability to scrollable content easily.

![](./demo.gif)

### Usage

```tsx
import { useDraggableScroll } from 'use-draggable-scroll';

const Component = () => {
  const ref = useRef(null);

  const { onMouseDown } = useDraggableScroll(ref);

  return (
    <div ref={ref} onMouseDown={onMouseDown}>
      <div>child 1</div>
      <div>child 2</div>
      <div>child 3</div>
    </div>
  );
};
```

### Optional parameters

You can specify the drag direction that is allowed (`vertical`, `horizontal` or `both`(default))

```tsx
const { onMouseDown } = useDraggableScroll(ref, { direction: 'vertical' });
```

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