1
1
/*!
2
- * vue-draggable-nested-tree v2.2.6
2
+ * vue-draggable-nested-tree v2.2.7
3
3
* (c) 2018-present phphe <phphe@outlook.com>
4
4
* Released under the MIT License.
5
5
*/
@@ -8,7 +8,7 @@ import assign from 'core-js/library/fn/object/assign';
8
8
import { breadthFirstSearch , insertAfter , insertBefore , appendTo , prependTo } from 'tree-helper' ;
9
9
import 'core-js/modules/web.dom.iterable' ;
10
10
import 'core-js/modules/es6.number.constructor' ;
11
- import { strRand , arrayRemove , getOffset , isOffsetInEl , binarySearch , hasClass } from 'helper-js' ;
11
+ import { strRand , arrayRemove , getOffset , binarySearch , hasClass } from 'helper-js' ;
12
12
import defineProperty from 'core-js/library/fn/object/define-property' ;
13
13
import 'core-js/modules/es6.function.name' ;
14
14
import 'core-js/modules/es6.array.find' ;
@@ -492,6 +492,45 @@ function attachCache(obj, cache, toCache) {
492
492
}
493
493
}
494
494
495
+ // from https://gist.github.com/iddan/54d5d9e58311b0495a91bf06de661380
496
+
497
+ if ( ! document . elementsFromPoint ) {
498
+ document . elementsFromPoint = elementsFromPoint ;
499
+ }
500
+
501
+ function elementsFromPoint ( x , y ) {
502
+ var parents = [ ] ;
503
+ var parent = void 0 ;
504
+
505
+ do {
506
+ if ( parent !== document . elementFromPoint ( x , y ) ) {
507
+ parent = document . elementFromPoint ( x , y ) ;
508
+ parents . push ( parent ) ;
509
+ parent . style . pointerEvents = 'none' ;
510
+ } else {
511
+ parent = false ;
512
+ }
513
+ } while ( parent ) ;
514
+
515
+ parents . forEach ( function ( parent ) {
516
+ return parent . style . pointerEvents = 'all' ;
517
+ } ) ;
518
+ return parents ;
519
+ }
520
+
521
+ function getTreeByPoint ( x , y , trees ) {
522
+ var els = document . elementsFromPoint ( x , y ) ;
523
+ var treeEL = els . find ( function ( el ) {
524
+ return hasClass ( el , 'tree' ) ;
525
+ } ) ;
526
+
527
+ if ( treeEL ) {
528
+ return trees . find ( function ( v ) {
529
+ return v . $el === treeEL ;
530
+ } ) ;
531
+ }
532
+ }
533
+
495
534
// 对 drag placeholder进行的操作
496
535
497
536
var targets = {
@@ -769,11 +808,8 @@ function autoMoveDragPlaceHolder(draggableHelperInfo) {
769
808
// right bottom point
770
809
// tree
771
810
currentTree : function currentTree ( ) {
772
- var _this = this ;
773
-
774
- var currentTree = trees . find ( function ( tree ) {
775
- return isOffsetInEl ( _this . offset . x , _this . offset . y , tree . $el ) ;
776
- } ) ;
811
+ // const currentTree = trees.find(tree => hp.isOffsetInEl(this.offset.x, this.offset.y, tree.$el))
812
+ var currentTree = getTreeByPoint ( this . offset . x , this . offset . y , trees ) ;
777
813
778
814
if ( currentTree ) {
779
815
var dragStartTree = this . store ;
@@ -805,10 +841,10 @@ function autoMoveDragPlaceHolder(draggableHelperInfo) {
805
841
} ,
806
842
// the second child of currentTree root, excluding dragging node
807
843
currentTreeRootSecondChildExcludingDragging : function currentTreeRootSecondChildExcludingDragging ( ) {
808
- var _this2 = this ;
844
+ var _this = this ;
809
845
810
846
return this . currentTree . rootData . children . slice ( 0 , 3 ) . filter ( function ( v ) {
811
- return v !== _this2 . node ;
847
+ return v !== _this . node ;
812
848
} ) [ 1 ] ;
813
849
} ,
814
850
// placeholder
0 commit comments