2020-06-30 05:11:03 +08:00
|
|
|
import Sortable from "sortablejs";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* SortableList
|
|
|
|
* @extends {Component}
|
|
|
|
*/
|
|
|
|
class SortableList {
|
|
|
|
setup() {
|
|
|
|
this.container = this.$el;
|
|
|
|
this.handleSelector = this.$opts.handleSelector;
|
|
|
|
|
2020-07-01 05:12:45 +08:00
|
|
|
const sortable = new Sortable(this.container, {
|
2020-06-30 05:11:03 +08:00
|
|
|
handle: this.handleSelector,
|
|
|
|
animation: 150,
|
2020-07-01 05:12:45 +08:00
|
|
|
onSort: () => {
|
|
|
|
this.$emit('sort', {ids: sortable.toArray()});
|
|
|
|
}
|
2020-06-30 05:11:03 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default SortableList;
|