@@ -9,27 +9,31 @@ import {
9
9
import { computeRenderContext } from "./core/renderHelper" ;
10
10
import { h , defineComponent , nextTick } from "vue" ;
11
11
12
- function computeVmIndex ( vNodes , element ) {
12
+ function computeVmIndex ( vNodes , htmlElement ) {
13
13
const domElements = vNodes . map ( ( { el } ) => el ) ;
14
- const index = domElements . indexOf ( element ) ;
14
+ const index = domElements . indexOf ( htmlElement ) ;
15
15
if ( index === - 1 ) {
16
16
throw new Error ( "node not found" , {
17
17
nodes : domElements ,
18
- element
18
+ htmlElement
19
19
} ) ;
20
20
}
21
21
return index ;
22
22
}
23
23
24
- function computeIndexes ( vNodes , domChildren , isTransition , footerOffset ) {
24
+ function computeIndexes (
25
+ vNodes ,
26
+ domChildren ,
27
+ { transitionMode, offsets : { footer : footerOffset } }
28
+ ) {
25
29
const domChildrenFromNodes = vNodes . map ( ( { el } ) => el ) ;
26
30
const footerIndex = domChildren . length - footerOffset ;
27
31
const rawIndexes = [ ...domChildren ] . map ( ( elt , idx ) =>
28
32
idx >= footerIndex
29
33
? domChildrenFromNodes . length
30
34
: domChildrenFromNodes . indexOf ( elt )
31
35
) ;
32
- return isTransition ? rawIndexes . filter ( ind => ind !== - 1 ) : rawIndexes ;
36
+ return transitionMode ? rawIndexes . filter ( ind => ind !== - 1 ) : rawIndexes ;
33
37
}
34
38
35
39
function emit ( evtName , evtData ) {
@@ -93,17 +97,9 @@ const draggableComponent = defineComponent({
93
97
94
98
props,
95
99
96
- data ( ) {
97
- return {
98
- noneFunctionalComponentMode : false
99
- } ;
100
- } ,
101
-
102
100
render ( ) {
103
101
const { $slots, $attrs, tag, componentData } = this ;
104
102
const renderContext = computeRenderContext ( { $slots, tag } ) ;
105
- this . renderContext = renderContext ;
106
- this . noneFunctionalComponentMode = renderContext . noneFunctional ;
107
103
const attributes = getComponentAttributes ( { $attrs, componentData } ) ;
108
104
109
105
if ( renderContext . noneFunctional && renderContext . transitionMode ) {
@@ -112,6 +108,7 @@ const draggableComponent = defineComponent({
112
108
) ;
113
109
}
114
110
111
+ this . renderContext = renderContext ;
115
112
return h ( renderContext . tag , attributes , renderContext . children ) ;
116
113
} ,
117
114
@@ -193,13 +190,13 @@ const draggableComponent = defineComponent({
193
190
194
191
getChildrenNodes ( ) {
195
192
const {
196
- noneFunctionalComponentMode,
197
193
renderContext : {
194
+ noneFunctional,
198
195
transitionMode,
199
196
nodes : { default : defaultNodes }
200
197
}
201
198
} = this ;
202
- if ( noneFunctionalComponentMode ) {
199
+ if ( noneFunctional ) {
203
200
//TODO check
204
201
return defaultNodes [ 0 ] . children ;
205
202
//return this.$children[0].$slots.default();
@@ -225,8 +222,7 @@ const draggableComponent = defineComponent({
225
222
this . visibleIndexes = computeIndexes (
226
223
this . getChildrenNodes ( ) ,
227
224
this . rootContainer . children ,
228
- this . renderContext . transitionMode ,
229
- this . renderContext . offsets . footer
225
+ this . renderContext
230
226
) ;
231
227
} ) ;
232
228
} ,
@@ -366,8 +362,8 @@ const draggableComponent = defineComponent({
366
362
} ;
367
363
const sendEvent = {
368
364
...evt ,
369
- ... { relatedContext } ,
370
- ... { draggedContext }
365
+ relatedContext,
366
+ draggedContext
371
367
} ;
372
368
return move ( sendEvent , originalEvent ) ;
373
369
} ,
0 commit comments