Basic list
A single sortable list. Drag any item up or down to reorder. This is the smallest useful Resortable setup.
- Write the spec
- Build the prototype
- Test with users
- Polish the UI
- Ship it
How it was wired
import { Sortable } from '../src/index.ts'
// Make a list sortable in one call. `draggable: '.sortable-item'`
// is the v2 default; we set it explicitly to match the migration
// guide and keep this example self-documenting.
new Sortable(document.getElementById('basic-list'), {
animation: 150,
draggable: '.sortable-item',
onEnd: (evt) => {
console.log(`moved ${evt.oldIndex} → ${evt.newIndex}`)
},
})