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

sortable-dnd

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sortable-dnd

JS Library for Drag and Drop, supports Sortable and Draggable

  • 0.0.10
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.4K
decreased by-11.85%
Maintainers
1
Weekly downloads
 
Created
Source

Downloads Version

A JS Library for Drag and Drop, supports Sortable and Draggable

Usage

HTML

<ul id="group">
  <li>
    <i>drag me</i>
    <p>1</p>
  </li>
  <li>
    <i>drag me</i>
    <p>2</p>
  </li>
  <li>
    <i>drag me</i>
    <p>3</p>
  </li>
</ul>

JavaScript

import Sortable from 'sortable-dnd'

var DND = new Sortable(
  document.getElementById('group'),
  {
    chosenClass: 'chosen',
    draggable: (e) => {
      return e.target.tagName === 'I' ? true : false
    },
    // or draggable: 'i'
    dragging: (e) => {
      return e.target
    },
    dragEnd: (old, new) => {
      ...
    }
  }
)

The component you created will clear all state after destroyed

Options

optiontypedefaultDescription
draggableString/Function-Specifies which items inside the element should be draggable, the function type must return a boolean
draggingFunction(e) => e.targetSpecifies the drag and drop element, which must return an HTMLElement
dragEndFunction(pre, cur) => {}The callback function when the drag is completed
ghostStyleObject{}The style of the mask element when dragging
ghostClassString''The class of the mask element when dragging
chosenClassString{}The class of the selected element when dragging
animationNumber150animation delay

Keywords

FAQs

Package last updated on 27 Apr 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