Sortable
Reorder elements in a list or across multiple lists.
Usage
The Sortable
class allows you to reorder elements in a list or across multiple lists.
Sortable elements are both Droppable and Draggable.
The Sortable
class is a thin wrapper that composes the Draggable
and Droppable
classes to make it simple to create sortable lists.
API Reference
Arguments
The Sortable
class accepts the following arguments:
The identifier of the sortable element. Should be unique within the same drag and drop context provider.
The element that should be made sortable. While this paramater is not required in the constructor, it is required to make the element sortable. You can update the element
on the instance after creating it.
Optionally supply a drag handle element to restrict initiating dragging to a specific element. If not provided, the entire element
will be draggable.
Optionally supply a type to only allow this sortable element to only be dropped over droppable targets that accept this type
.
Optionally supply a type of draggable element to only allow it to be dropped over certina droppable targets that accept this type
.
Optionally supply a collision detector function can be used to detect collisions between the droppable element and draggable elements.
Optionally supply a number to set the collision priority of the droppable element. The higher the number, the higher the priority when detecting collisions. This can be useful if there are multiple droppable elements that overlap.
Set to true
to prevent the sortable element from being sortable.
An array of modifiers that can be used to modify or restrict the behavior of the sortable element.
An array of sensors that can be bound to the sortable element to detect drag interactions.
The data argument is for advanced use-cases where you may need access to additional data about the sortable element in event handlers, modifiers, sensors or custom plugins.
destroy()
method of this instance.