@@ -466,7 +466,6 @@ export default function makeTreeDraggable(treeEl, options = {}) {
466
466
}
467
467
//
468
468
store . targetPath = options . getPathByBranchEl ( placeholder )
469
- store . isDownwardsSameLevelMove = isDownwardsSameLevelMove ( )
470
469
let pathChanged = isPathChanged ( )
471
470
store . targetPathNotEqualToStartPath = pathChanged
472
471
store . pathChangePrevented = false
@@ -496,15 +495,21 @@ export default function makeTreeDraggable(treeEl, options = {}) {
496
495
}
497
496
//
498
497
function isPathChanged ( ) {
499
- const { startTree, targetTree, startPath, targetPath, isDownwardsSameLevelMove} = store
500
- if ( isDownwardsSameLevelMove ) {
501
- return hp . arrayLast ( startPath ) < hp . arrayLast ( targetPath ) - 1 // if equal, not moved
502
- }
503
- return startTree !== targetTree || startPath . toString ( ) !== targetPath . toString ( )
504
- }
505
- function isDownwardsSameLevelMove ( ) {
506
498
const { startTree, targetTree, startPath, targetPath} = store
507
- return startTree === targetTree && startPath . length === targetPath . length && startPath . slice ( 0 , startPath . length - 1 ) . toString ( ) === targetPath . slice ( 0 , targetPath . length - 1 ) . toString ( ) && hp . arrayLast ( startPath ) < hp . arrayLast ( targetPath )
499
+ if ( startTree === targetTree && startPath . length === targetPath . length ) {
500
+ if ( startPath . toString ( ) === targetPath . toString ( ) ) {
501
+ return false
502
+ } else {
503
+ // downward same-level move, the end of targetPath is 1 more than real value
504
+ // 同级向下移动时, targetPath的末位比真实值大1
505
+ const t = startPath . slice ( 0 )
506
+ t [ t . length - 1 ] ++
507
+ if ( t . toString ( ) === targetPath . toString ( ) ) {
508
+ return false
509
+ }
510
+ }
511
+ }
512
+ return true
508
513
}
509
514
} ,
510
515
} )
0 commit comments