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

react-tnm-drag

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-tnm-drag

Package to allow easy drag and drop of React components

  • 0.5.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

React Touch N Mouse Drag

Package to allow easy drag and drop of React components with full type anotation

Github page

Installation

npm install react-tnm-drag

Usage

import { useDragReducer, useDrag, useDragContainer } from 'react-tnm-drag'

const { dragState, dragReducer } = useDragReducer(
  "number",         // [Required] string with the item.id type (either "number" or "string")
  "number",         // string with the container identifier type (If there are several arrays)
  "string"          // string with the container of the container identifier type (If there are several arrays of arrays)
)

const propsForDraggableItem = useDrag(
  dragState,        // [Required] Comes from useDragReducer
  dragReducer,      // [Required] Comes from useDragReducer
  item.id,          // [Required] identifier (Should be the type as the first parameter of useDragReducer)
  index,            // [Required] Array index of the item
  performMovement,  // [Required] Function you give to actually move the item in the array probably with some array.splice()
  "horizontal",     // string with the direction of the list (Defaults to "vertical")
  desapearDelay,    // ms after dropping until the dragged item will dissapear (Defaults to 0)
  ref               // React.refObject from the component (Will be created internally if not provided)
)

const propsForContainer = useDragContainer(
  "oneContainer",   // [Required] string stating which container this function is for (either "oneContainer", "firstContainer" or "secondContainer")
  dragState,        // [Required] Comes from useDragReducer
  dragReducer,      // [Required] Comes from useDragReducer
  container.id,     // [Required] identifier (Should be the type as the first parameter of useDragReducer)
  index,            // [Required] Array index of the item
)

See the example [react project] for more details (Coming soon)

Keywords

FAQs

Package last updated on 01 Oct 2022

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