An open API service indexing awesome lists of open source software.

https://github.com/zaibot/react-dnd

D&D with freedom
https://github.com/zaibot/react-dnd

Last synced: 3 months ago
JSON representation

D&D with freedom

Awesome Lists containing this project

README

        

![build status](https://travis-ci.org/Zaibot/react-dnd.svg?branch=master)

# @zaibot/react-dnd

[Demo / Documentation](https://zaibot.github.io/react-dnd/)

## Terminology

| Name | Meaning |
| - | - |
| Draggable | Container used for cloned image |
| Dragging | Cloned image |
| Drag Container Props | Positioning props for cloned image |
| Drag Handle Props | Event props for drag handle |
| Drop Props | Event props for dropping container |
| Tracking | Container used for calculating positioning |
| Container | HTML element of/wrapping your content |
| Handle | Specific actionable part within a draggable |
| Key | Information used to identify the information to be dragged |
| Data | The data object to be received during a drop |
| Meta | Additional information related to action of dragging |

## Usage

Required root for information sharing
```js
import { DraggingProvider } from '@zaibot/react-dnd';

ReactDOM.render(


...


)
```

Drop area
```js
import { Droppable } from '@zaibot/react-dnd';

const DropArea = () => (
{ ... }}>
{({ dropProps, trackingProps }) => (


...

)}

)
```

Draggable
```js
import { Droppable } from '@zaibot/react-dnd';

const DragMe = () => (

{({ isDragged, dragContainerProps, dragHandleProps, trackingProps, dragging }) => (

{dragging}Drag me

)}

)
```

Re-order Area
```js
import { Draggable, Droppable, PositionContainer, PositionPublisher } from '@zaibot/react-dnd';

const DropArea = () => (

{({ ref, registries }) => (
{ ... }}>
{({ dropProps, trackingProps }) => (


...

)}

)}

)

const DragMe = () => (

{({ refContainer }) => (

{({ isDragged, dragContainerProps, dragHandleProps, trackingProps, dragging }) => (

{dragging}Drag me

)}

)}

)
```

## Resources

https://developer.mozilla.org/en-US/docs/Web/API/HTML_Drag_and_Drop_API