# use-draggable-svg

> React hook to drag SVG objects

Latest version **1.0.0** (published 2021-06-03) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2021-06-03 |
| First published | 2021-06-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 22.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | motiko |
| Maintainers | motiko |

## Links

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

## Recent versions

- 1.0.0 (latest) — 2021-06-03

## README

# use-draggable-svg

> React hook to drag SVG objects

[![NPM](https://img.shields.io/npm/v/use-draggable-svg.svg)](https://www.npmjs.com/package/use-draggable-svg) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save use-draggable-svg
```

## Usage

```tsx
import React, { useRef } from 'react'

import useDraggable from 'use-draggable-svg'

const App = () => {
  const containerRef = useRef<any>()
  const { startDrag } = useDraggable({
    containerRef,
    onDragEnd: ({ from, to }) => console.log(from, to)
  })

  return (
    <svg viewBox='0 0 30 20' ref={containerRef} fill="lightgray">
      <svg
        onMouseDown={startDrag}
        onTouchStart={startDrag}
        viewBox='0 0 300 200'
        x='10'
        y='3'
      >
        <rect width='20' height='30' fill='lightgreen' />
      </svg>
      <svg
        onMouseDown={startDrag}
        onTouchStart={startDrag}
        viewBox='0 0 300 200'
        x='18'
        y='5'
      >
        <rect width='30' height='20' fill='gray' />
      </svg>
    </svg>
  )
}

export default App
```

## License

MIT © [motiko](https://github.com/motiko)

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