提交 1fed4eeb 编写于 作者: O owen-m1

Improve OnSpill support with multiple sortables + fix drop events

上级 99c8695b
......@@ -17,7 +17,7 @@ const drop = function({
if (toSortable && !toSortable.el.contains(target)) {
dispatchSortableEvent('spill');
this.onSpill(dragEl);
this.onSpill({ dragEl, putSortable });
}
};
......@@ -28,8 +28,11 @@ Revert.prototype = {
dragStart({ oldDraggableIndex }) {
this.startIndex = oldDraggableIndex;
},
onSpill(dragEl) {
onSpill({ dragEl, putSortable }) {
this.sortable.captureAnimationState();
if (putSortable) {
putSortable.captureAnimationState();
}
let nextSibling = getChild(this.sortable.el, this.startIndex, this.sortable.options);
if (nextSibling) {
......@@ -38,6 +41,9 @@ Revert.prototype = {
this.sortable.el.appendChild(dragEl);
}
this.sortable.animateAll();
if (putSortable) {
putSortable.animateAll();
}
},
drop
};
......@@ -50,10 +56,11 @@ Object.assign(Revert, {
function Remove() {}
Remove.prototype = {
onSpill(dragEl) {
this.sortable.captureAnimationState();
onSpill({ dragEl, putSortable }) {
const parentSortable = putSortable || this.sortable;
parentSortable.captureAnimationState();
dragEl.parentNode && dragEl.parentNode.removeChild(dragEl);
this.sortable.animateAll();
parentSortable.animateAll();
},
drop
};
......
......@@ -28,7 +28,11 @@ This plugin, when enabled, will cause the dragged item to be reverted to it's or
```js
new Sortable(el, {
revertOnSpill: false // Enable plugin
revertOnSpill: false, // Enable plugin
// Called when item is spilled
onSpill: function(/**Event*/evt) {
evt.item // The spilled item
}
});
```
......@@ -47,6 +51,10 @@ This plugin, when enabled, will cause the dragged item to be removed from the DO
```js
new Sortable(el, {
removeOnSpill: false // Enable plugin
removeOnSpill: false, // Enable plugin
// Called when item is spilled
onSpill: function(/**Event*/evt) {
evt.item // The spilled item
}
});
```
......@@ -1284,6 +1284,8 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
evt
});
parentEl = dragEl.parentNode;
// Get again after plugin event
newIndex = index(dragEl);
newDraggableIndex = index(dragEl, options.draggable);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册