1.0.1 • Published 4 years ago

react-draggable-wrapper v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

react-draggable-wrapper

React draggable wrapper component encapsulating the HTML5 Drag and Drop APIs.

HTML5 Drag and Drop

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

How to use

Import the module from here

import DraggableWrapper from 'react-draggable-wrapper';

Wrap any React component which requires Drag and Drop feature by DraggableWrapper.

<DraggableWrapper
      id={...}
      handleDragStart={...}
      handleDrop={...}
      handleDragOver={...}
    >
    <div> drag me </div>
 </DraggableWrapper>

API reference

Props

Following props main props are accepted

PropTypeUsageDefault
idanyUniquely identify a dragging element0
isDraggablebooleanAllow drag and droptrue
handleDragStartfunction: (event, id) => {...}Will trigger at onDragStart-
handleDropfunction: (event, id) => {...}Will trigger at onDrop-
handleDragOverfunction: (event, id) => {...}Will trigger at onDragOver-
handleDragEnterfunction: (event, id) => {...}Will trigger at onDragEnter-
handleDragLeavefunction: (event, id) => {...}Will trigger at onDragLeave-
handleDragExitfunction: (event, id) => {...}Will trigger at onDragExit-
handleDragEndfunction: (event, id) => {...}Will trigger at onDragEnd-

Other than above main props, additional props such as style, data-id can be passed to the wrapper.

Example

A reference implementation of a row drag and drop is provided here. Below is a screen casting of the application.

Row and Drop