提交 5afb802a 编写于 作者: O owen-m1

#1954: Add useAnimation option to sort()

上级 a0e160a5
......@@ -565,12 +565,12 @@ For each element in the set, get the first element that matches the selector by
Serializes the sortable's item `data-id`'s (`dataIdAttr` option) into an array of string.
##### sort(order:`String[]`)
##### sort(order:`String[]`, useAnimation:`Boolean`)
Sorts the elements according to the array.
```js
var order = sortable.toArray();
sortable.sort(order.reverse()); // apply
sortable.sort(order.reverse(), true); // apply
```
......
......@@ -1569,7 +1569,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
* Sorts the elements according to the array.
* @param {String[]} order order of the items
*/
sort: function (order) {
sort: function (order, useAnimation) {
let items = {}, rootEl = this.el;
this.toArray().forEach(function (id, i) {
......@@ -1580,12 +1580,14 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
}
}, this);
useAnimation && this.captureAnimationState();
order.forEach(function (id) {
if (items[id]) {
rootEl.removeChild(items[id]);
rootEl.appendChild(items[id]);
}
});
useAnimation && this.animateAll();
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册