@@ -23,10 +23,11 @@ export default {
23
23
minTranslate: 10 ,
24
24
drag : (e , opt , store ) => {
25
25
// this store is not tree
26
- if (this .store .ondragstart && this .store .ondragstart (this .data , this , this .store , e, opt, store) === false ) {
26
+ const draggableHelperInfo = {event : e, options: opt, store}
27
+ if (this .store .ondragstart && this .store .ondragstart (this .data , draggableHelperInfo) === false ) {
27
28
return false
28
29
}
29
- if (! isNodeDraggable (this .data , this )) {
30
+ if (! isNodeDraggable (this .data )) {
30
31
return false
31
32
}
32
33
// record start positon
@@ -36,46 +37,51 @@ export default {
36
37
dplh .innerStyle .height = store .el .offsetHeight + ' px'
37
38
th .insertAfter (dplh, this .data )
38
39
this .data .class += ' dragging'
40
+ this .store .$emit (' drag' , this .data )
39
41
// console.log('drag start');
40
42
},
41
43
moving : (e , opt , store ) => {
42
- return autoMoveDragPlaceHolder .call (this , e, opt, store, this .store .trees )
44
+ const draggableHelperInfo = {event : e, options: opt, store}
45
+ return autoMoveDragPlaceHolder .call (this , draggableHelperInfo)
43
46
},
44
47
drop : (e , opt , store ) => {
45
- if (this .store .ondragend && this .store .ondragend (this .data , this , this .store , e, opt, store) === false ) {
48
+ const draggableHelperInfo = {event : e, options: opt, store}
49
+ if (this .store .ondragend && this .store .ondragend (this .data , draggableHelperInfo) === false ) {
46
50
// can't drop, no change
47
51
} else {
52
+ const targetTree = dplh ._vm .store
53
+ const crossTree = targetTree !== this .store
54
+ const oldTree = crossTree ? this .store : null
48
55
th .insertAfter (this .data , dplh)
49
56
hp .arrayRemove (dplh .parent .children , dplh)
50
57
this .data .class = this .data .class .replace (/ (^ | )dragging( | $ )/ g , ' ' )
58
+ targetTree .$emit (' drop' , this .data , targetTree, oldTree)
59
+ oldTree && oldTree .$emit (' drop' , this .data , targetTree, oldTree)
51
60
// emit change event if changed
52
61
const siblings = this .data .parent .children
53
62
if (siblings === this .startPosition .siblings && siblings .indexOf (this .data ) === this .startPosition .index ) {
54
63
// not moved
55
64
} else {
56
- this .store .$emit (' change' , this .data , this , this .store )
65
+ this .store .$emit (' change' , this .data , targetTree, oldTree)
66
+ oldTree && oldTree .$emit (' change' , this .data , targetTree, oldTree)
57
67
}
58
- delete this .startPosition
68
+ this .startPosition = null
59
69
}
60
- this .store .$emit (' drop' , this .data , this , this .store )
61
70
// console.log('drag end');
62
71
},
63
72
})
64
73
} else {
65
74
if (this ._draggableDestroy ) {
66
75
this ._draggableDestroy ()
67
- delete this ._draggableDestroy
76
+ this ._draggableDestroy = null
68
77
}
69
78
}
70
79
}, {immediate: true })
71
80
},
72
81
}
73
82
74
83
function isNodeDraggable (node , nodeVm ) {
75
- const {store } = nodeVm
76
- if (store .isNodeDraggable ) {
77
- return store .isNodeDraggable (node, nodeVm, store)
78
- } else if (node .hasOwnProperty (' draggable' )) {
84
+ if (node .hasOwnProperty (' draggable' )) {
79
85
return node .draggable
80
86
} else {
81
87
return true
0 commit comments