Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

drag-list-react

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drag-list-react

A component of dragging and resorting list for React

  • 1.0.2
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Drag-list-react

npm Build Status npm

A HOC component of Drag&Drop,Touch enabled and Reordering list for React.

Install

npm install drag-list-react --save

Usage

import React from 'react';
import DragList from 'drag-list-react';
// Data list
const list=[
  {
    id:1,
    name:'Item1'
  },{
    id:2,
    name:'Item2'
  },{
    id:3,
    name:'Item3'
  },{
    id:4,
    name:'Item4'
  }
]

// list item
// Each properties in data list will be passed to the children
const listItem=({name})=>(
  <div className={styles.nameTag}>{name}</div>
)

// Placeholder when dragging items
// Props is necessary because placeholder will receive style props from component.
const Placeholder=(props)=>(
  <div className={styles.placeholder} {...props}></div>  
)

const App = () => {
  // Use placeholder
  const List = DragList(listItem,Placeholder);
  // Or not use placeholder
  // const List = DragList(listItem);
  return (
    <List  />
  )
};

API

Properties

nametypedefaultdescription
typeStringType of drag list.The list will be horizontal when it is set inline.
isLongPressBooleanfalseShould dragging be triggered by long pressing or not
delayNumber300(ms)The delay time of long pressing
gutterNumber0The spacing between two items
onDragBeginFunction(item,index,element)Prams: item is the dragging element of your data array; index is the index of the dragging item in your data array; element is the real DOM node of your dragging item.
onDragEndFunction(list)Param: list is the final list when dragging ends.

Keywords

FAQs

Package last updated on 06 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc