Extras
Sortable
Bit.BlazorUI.ExtrasSortableListReorderableListDragAndDropList
BitSortable is a drag-and-drop sortable list, inspired by SortableJS: reorder the items of a list, or drag them between lists that share a Group - with live reordering, slide animations, clone and move pull modes, swap thresholds, drag handles, filters, nested lists, swap mode, multi-drag and the keyboard, every step announced to screen readers.
Layout & nesting
Swap thresholds and the inverted swap zone, grids and horizontal lists, and lists nested inside the items of other lists.
Swap thresholds
SwapThreshold is the part of an item, across its middle, that the pointer has to reach before the dragged
item swaps past it; a smaller one leaves a dead zone near each edge. InvertSwap moves the zones to the edges
of the item, InvertedSwapThreshold wide, for a sort-between-items feel. Direction says along which
axis the zones run. The tinted bands show the zones. This mirrors the SortableJS thresholds demo.
- Set SwapThreshold to 1: the whole item is the zone, and the dragged item swaps as soon as the pointer enters the next one. Set it to 0.2: the pointer has to reach the thin band in the middle, and the edges around it do nothing.
- Turn InvertSwap on: entering the top or bottom band of an item puts the dragged one before or after it - a "drop between the items" feel. InvertedSwapThreshold sizes the two edge bands together; left at 0 it takes SwapThreshold.
- Swap an item past the next one and move the pointer back a little: the area the dragged item has just left - its shadow - swaps it back. That rule, ported from SortableJS, keeps a short item and a tall one from trading places back and forth while the pointer sits still.
- An item that enters a list it is not in yet always uses the inverted zones, whatever InvertSwap says, so it can be dropped before the first item as easily as after the last.
Item 1
Item 2
Item 3
Item 4
Item 5
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
Grid & horizontal lists
The list does not mind its layout: laid out as a CSS grid it is a sortable grid, as a wrapping row a horizontal
list. Its items are measured as they are laid out, so a grid sorts across a row and from row to row. The
default Direction, Auto, tells the axis from the layout; the row of tags sets it.
- Auto reads the first two items: side by side is horizontal, anything else vertical. With a single item in view it reads the list instead: a flex row, or a grid of several columns, is horizontal, a flex column vertical. Set Direction when the layout says otherwise - in a grid, whose first two items sit side by side although the list also runs down.
- The hit test is two-dimensional, so a grid sorts in every direction whatever Direction says: Direction only decides which way an item's swap zones run (see Swap thresholds).
- The item wrappers are the direct children of the list's root, so the grid or the flex row lays them out: style them with ItemClass or Classes.Item, or style the template inside them. A list reversed with flex-direction: row-reverse or column-reverse is measured in its own order, as a right-to-left one is.
- Drag square 1 onto square 7, a row down: it sorts across rows, not only along one. From the keyboard the arrows follow the layout: left and right along a row, up and down from row to row.
1
2
3
4
5
6
7
8
9
10
11
12
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
blazor
dotnet
drag-and-drop
sortable
css
a11y
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
Nested lists
A list can render another one inside each of its items. Every level shares the group, so an item - with its
children - moves from branch to branch and from depth to depth. Each item renders a list of its own, empty or not,
so any item can take children. Each list is bound one way, with Items, to its item's children, which it changes in
place; ItemsChanged only tells the page to render the tree again. SwapThreshold 0.65 is the value the SortableJS
nested demo uses: the outer part of each item is a dead zone.
- An item is never dropped inside itself: the lists in the dragged item's own subtree, and those inside the drop preview, refuse it - drag Item 1.1 over its own children and none takes it.
- Each list handles its own items only: a drag that starts in an inner list is not also a drag of the outer item around it.
- A nested list takes the pointer only for a drag it could receive. One of another group, of another item type, or with Put="false" leaves the drag to the list around it - which is how the columns of a board still sort while the pointer crosses the card lists inside them.
- From the keyboard, the arrows carry a picked-up item into a nested list and out again, in the direction they point.
Item 1.1
Item 2.1
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
Item 2.2
Item 3.1
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
Item 3.2
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
Item 2.3
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
Item 1.2
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
Item 1.3
Item 2.4
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
Item 2.5
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
Item 1.4
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
To pick up the item, press Space or Enter. While it is picked up, the arrow keys move it, Home and End move it to the start or the end of its list, Space or Enter drops it, and Escape puts it back.
Tree: Item 1.1 [Item 2.1, Item 2.2 [Item 3.1, Item 3.2], Item 2.3], Item 1.2, Item 1.3 [Item 2.4, Item 2.5], Item 1.4
Feedback
Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.