Skip to content

Commit cc9bb82

Browse files
Refactoring
1 parent fd9bd4b commit cc9bb82

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/vuedraggable.js

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function computeVmIndex(vNodes, element) {
1515
if (index === -1) {
1616
throw new Error("node not found", {
1717
nodes: domElements,
18-
element,
18+
element
1919
});
2020
}
2121
return index;
@@ -322,7 +322,7 @@ const draggableComponent = defineComponent({
322322
}
323323
const list = component.realList;
324324
const context = { list, component };
325-
if (to !== related && list && component.getUnderlyingVm) {
325+
if (to !== related && list) {
326326
const destination = component.getUnderlyingVm(related);
327327
if (destination) {
328328
return Object.assign(destination, context);
@@ -400,20 +400,23 @@ const draggableComponent = defineComponent({
400400
},
401401

402402
onDragMove(evt, originalEvent) {
403-
const onMove = this.move;
404-
if (!onMove || !this.realList) {
403+
const { move, realList } = this;
404+
if (!move || !realList) {
405405
return true;
406406
}
407407

408408
const relatedContext = this.getRelatedContextFromMoveEvent(evt);
409-
const draggedContext = this.context;
410409
const futureIndex = this.computeFutureIndex(relatedContext, evt);
411-
Object.assign(draggedContext, { futureIndex });
412-
const sendEvt = Object.assign({}, evt, {
413-
relatedContext,
414-
draggedContext
415-
});
416-
return onMove(sendEvt, originalEvent);
410+
const draggedContext = {
411+
...this.context,
412+
futureIndex
413+
};
414+
const sendEvt = {
415+
...evt,
416+
...{ relatedContext },
417+
...{ draggedContext }
418+
};
419+
return move(sendEvt, originalEvent);
417420
},
418421

419422
onDragEnd() {

0 commit comments

Comments
 (0)