@duongtdn/react-drag-component
v1.1.0
Published
React Drag component
Downloads
5
Readme
@interactivity/drag-component
Installation
npm install --save @interactivity/drag-component
Usage
example code
"use strict"
import React from "react";
import { DragContainer, DragHolder, DragItem } from "@interactivity/drag-component";
const DragPlayground = () => (
<DragContainer alignHolderSize = {true} onDragEnd = { status => console.log(status)}>
<h2> Drag Playground </h2>
<div className="flex-container flex-direction-row">
<div style = {{ flex: 1}} >
<DragHolder direction = "column"
id = "holder_1"
stretch
minHeight = {40}
>
<Draggable id = "red" mode = {mode}>
<div className = "red" style = {{height: '40px'}}> Drag me!</div>
</Draggable>
<Draggable id = "green" mode = {mode}>
<div className = "green" style = {{height: '40px'}}> Drag me!</div>
</Draggable>
</DragHolder>
</div>
<div style = {{ flex: 1}} >
<DragHolder direction = "column"
id = "holder_1"
stretch
minHeight = {40}
>
<Draggable id = "blue" mode = {mode}>
<div className = "blue" style = {{height: '40px'}}> Drag me!</div>
</Draggable>
</DragHolder>
</div>
</div>
</DragContainer>
);DragContainer
Control the draggable zone. It manages DragHolder and DragItem components
Props:
width:
optionalspecify fixed width in pixel of the drag zoneheight:
optionalspecify fixed height in pixel of the drag zonealignHolderSize:
default = falseall holder with same direction will be aligned in their main dimensionfixedHolderLength:
default = falsespecify if all holders have their length (width or height depend on its direction) equal to total item lengthinitState:
optionalinitial state of holders and itemsonDragEnd:
optionalcallback that receive internal status of holders and items
DragHolder
Holder storing draggable items which operate in flow mode.
Props:
id:
mandatoryID of DragHolderdirection:
mandatorygrowth direction of the holder when items are added, i.e.roworcolumnstretch:
optionalthe holder width will be 100%. It overrides thealignHolderSize. Note thatstretchonly work withdirection = rowand does not affect toheightsize:
optionalan object{width, height}specifing fixed width or heigtht of the holderminWidth:
optionalspecify minWidth of the holderminHeight:
optionalspecify minHeight of the holder
Draggable
Wrap element in an draggable item
Props:
id:
mandatoryID of Draggablemode:
default = flow. Inflowmode, drag item is only stay inside a holder, infreemode, drag item can be drag anywhere
