sortablejs
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
Sortablejs is a JavaScript library that allows users to create reorderable drag-and-drop lists on modern browsers and touch devices. No dependency on jQuery is required. The library supports Meteor, AngularJS, React, Polymer, Vue, Knockout, and any CSS libraries like Bootstrap. It features advanced capabilities such as touch device support, CSS animations upon moving items, smart auto-scrolling, support for CSS transforms, and multi-drag support among many others.
To use sortablejs in your JavaScript project, first install it using NPM or Bower using the commands npm install sortablejs --save
or bower install --save sortablejs
. Then, import it into your project as needed:
// Default SortableJS
import Sortable from 'sortablejs';
Next, create a sortable instance in your JavaScript code by calling Sortable.create
with the id of the HTML element you want to make sortable. For example:
<ul id="items">
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
</ul>
var el = document.getElementById('items');
var sortable = Sortable.create(el);
Additional options can be set as well to control the behavior of the sortable instance:
var sortable = new Sortable(el, {
group: "name",
sort: true,
animation: 150,
handle: ".my-handle",
disabled: false,
});
The full documentation for sortablejs, including detailed API descriptions, usage examples, optional configurations, and more can be found at the GitHub repository - https://github.com/SortableJS/Sortable. The npm package details are available on npmjs.com/package/sortablejs.