Create sortable list
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
element |
HTMLElement | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
options |
object |
optional
|
Fires:
- event:pickup
- event:order
- event:add
- event:remove
- event:update
- event:delete
- event:copy
- event:maximum-remove
- event:order-pending
- event:add-pending
- event:remove-pending
- event:add-remove-pending
- event:update-pending
- event:delete-pending
- event:copy-pending
- event:maximum-remove-pending
- event:clicked
Members
-
the global defaults for new Sortable objects
Methods
-
create multiple sortable elements
Name Type Description elementsArray.<HTMLElements> optionsobject see constructor for options
-
add an element as a child of the sortable element; can also be used to swap between sortables NOTE: this may not work with deepSearch non-ordered elements; use attachElement instead
Name Type Description elementHTMLElement indexnumber -
attaches an HTML element to the sortable; can also be used to swap between sortables NOTE: you need to manually insert the element into this.element (this is useful when you have a deep structure)
Name Type Description elementHTMLElement -
removes all event handlers from this.element and children
-
removes all events from an HTML element NOTE: does not remove the element from its parent
Name Type Description elementHTMLElement
Type Definitions
-
Options for Sortable
Properties:
Name Type Argument Default Description options.namestring <optional>
sortable dragging is allowed between Sortables with the same name
options.dragClassstring <optional>
if set then drag only items with this className under element; otherwise drag all children
options.orderClassstring <optional>
use this class to include elements in ordering but not dragging; otherwise all children elements are included in when sorting and ordering
options.deepSearchboolean <optional>
if dragClass and deepSearch then search all descendents of element for dragClass
options.sortboolean <optional>
true allow sorting within list
options.dropboolean <optional>
true allow drop from related sortables (doesn't impact reordering this sortable's children until the children are moved to a differen sortable)
options.copyboolean <optional>
false create copy when dragging an item (this disables sort=true for this sortable)
options.orderIdstring <optional>
data-order for ordered lists, use this data id to figure out sort order
options.orderIdIsNumberboolean <optional>
true use parseInt on options.sortId to properly sort numbers
options.reverseOrderstring <optional>
reverse sort the orderId
options.offListstring <optional>
closest how to handle when an element is dropped outside a sortable: closest=drop in closest sortable; cancel=return to starting sortable; delete=remove from all sortables
options.maximumnumber <optional>
maximum number of elements allowed in a sortable list
options.maximumFIFOboolean <optional>
whether to use first-in-first-out (or last-in-first-out) to choose which item to remove when maximum is reached
options.cursorHoverstring <optional>
grab -webkit-grab pointer use this cursor list to set cursor when hovering over a sortable element
options.cursorDownstring <optional>
grabbing -webkit-grabbing pointer use this cursor list to set cursor when mousedown/touchdown over a sortable element
options.thresholdnumber <optional>
10 minimum movement distance in pixels before calculating a movement
options.useIconsboolean <optional>
true show icons when dragging
options.iconsobject <optional>
default set of icons
Properties
Name Type Argument Description reorderstring <optional>
movestring <optional>
copystring <optional>
deletestring <optional>
options.customIconstring <optional>
source of custom image when over this sortable
Events
-
fires when an element is added to this sortable
Properties:
Name Type Description elementHTMLElement added
sortableSortable where element was added
-
fires when element is added but not dropped yet
Properties:
Name Type Description elementHTMLElement being dragged
currentSortable sortable with element placeholder
-
fires when element is removed after being temporarily added
Properties:
Name Type Description elementHTMLElement being dragged
currentSortable sortable with element placeholder
-
fires when an element is clicked without dragging
Properties:
Name Type Description elementHTMLElement clicked
sortableSortable where element is a child
-
fires when a copy of an element is dropped
Properties:
Name Type Description elementHTMLElement removed
sortableSortable where element was dragged from
-
fires when a copy of an element is about to drop
Properties:
Name Type Description elementHTMLElement removed
sortableSortable where element was dragged from
-
fires when an element is removed from all sortables
Properties:
Name Type Description elementHTMLElement removed
sortableSortable where element was dragged from
-
fires when an element is about to be removed from all sortables
Properties:
Name Type Description elementHTMLElement removed
sortableSortable where element was dragged from
-
fires when an element is removed because maximum was reached for the sortable
Properties:
Name Type Description elementHTMLElement removed
sortableSortable where element was dragged from
-
fires when an element is about to be removed because maximum was reached for the sortable
Properties:
Name Type Description elementHTMLElement removed
sortableSortable where element was dragged from
-
fires when a sortable is reordered
Properties:
Name Type Description elementHTMLElement that was reordered
sortableSortable where element was placed
-
fires when order was changed but element was not dropped yet
Properties:
Name Type Description elementHTMLElement being dragged
currentSortable sortable with element placeholder
-
fires when an element is picked up because it was moved beyond the options.threshold
Properties:
Name Type Description elementHTMLElement being dragged
currentSortable sortable with element placeholder
-
fires when an element is removed from this sortable
Properties:
Name Type Description elementHTMLElement removed
sortableSortable where element was removed
-
fires when element is removed but not dropped yet
Properties:
Name Type Description elementHTMLElement being dragged
currentSortable sortable with element placeholder
-
fires when the sortable is updated with an add, remove, or order change
Properties:
Name Type Description elementHTMLElement changed
sortableSortable with element
-
fires when an element is added, removed, or reorder but element has not dropped yet
Properties:
Name Type Description elementHTMLElement being dragged
currentSortable sortable with element placeholder