@@ -120,6 +120,10 @@ let dragEl,
120
120
121
121
tapEvt ,
122
122
touchEvt ,
123
+ lastDx ,
124
+ lastDy ,
125
+ tapDistanceLeft ,
126
+ tapDistanceTop ,
123
127
124
128
moved ,
125
129
@@ -548,6 +552,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
548
552
el = _this . el ,
549
553
options = _this . options ,
550
554
ownerDocument = el . ownerDocument ,
555
+ dragRect = getRect ( target ) ,
551
556
dragStartFn ;
552
557
553
558
if ( target && ! dragEl && ( target . parentNode === el ) ) {
@@ -566,6 +571,9 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
566
571
clientY : ( touch || evt ) . clientY
567
572
} ;
568
573
574
+ tapDistanceLeft = tapEvt . clientX - dragRect . left ;
575
+ tapDistanceTop = tapEvt . clientY - dragRect . top ;
576
+
569
577
this . _lastX = ( touch || evt ) . clientX ;
570
578
this . _lastY = ( touch || evt ) . clientY ;
571
579
@@ -789,8 +797,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
789
797
+ ( relativeScrollOffset ? ( relativeScrollOffset [ 0 ] - ghostRelativeParentInitialScroll [ 0 ] ) : 0 ) / ( scaleX || 1 ) ,
790
798
dy = ( ( touch . clientY - tapEvt . clientY )
791
799
+ fallbackOffset . y ) / ( scaleY || 1 )
792
- + ( relativeScrollOffset ? ( relativeScrollOffset [ 1 ] - ghostRelativeParentInitialScroll [ 1 ] ) : 0 ) / ( scaleY || 1 ) ,
793
- translate3d = evt . touches ? 'translate3d(' + dx + 'px,' + dy + 'px,0)' : 'translate(' + dx + 'px,' + dy + 'px)' ;
800
+ + ( relativeScrollOffset ? ( relativeScrollOffset [ 1 ] - ghostRelativeParentInitialScroll [ 1 ] ) : 0 ) / ( scaleY || 1 ) ;
794
801
795
802
// only set the status to dragging, when we are actually dragging
796
803
if ( ! Sortable . active && ! awaitingDragStarted ) {
@@ -802,12 +809,33 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
802
809
this . _onDragStart ( evt , true ) ;
803
810
}
804
811
805
- touchEvt = touch ;
812
+ if ( ghostEl ) {
813
+ if ( ghostMatrix ) {
814
+ ghostMatrix . e += dx - ( lastDx || 0 ) ;
815
+ ghostMatrix . f += dy - ( lastDy || 0 ) ;
816
+ } else {
817
+ ghostMatrix = {
818
+ a : 1 ,
819
+ b : 0 ,
820
+ c : 0 ,
821
+ d : 1 ,
822
+ e : dx ,
823
+ f : dy
824
+ } ;
825
+ }
826
+
827
+ let cssMatrix = `matrix(${ ghostMatrix . a } ,${ ghostMatrix . b } ,${ ghostMatrix . c } ,${ ghostMatrix . d } ,${ ghostMatrix . e } ,${ ghostMatrix . f } )` ;
828
+
829
+ css ( ghostEl , 'webkitTransform' , cssMatrix ) ;
830
+ css ( ghostEl , 'mozTransform' , cssMatrix ) ;
831
+ css ( ghostEl , 'msTransform' , cssMatrix ) ;
832
+ css ( ghostEl , 'transform' , cssMatrix ) ;
806
833
807
- css ( ghostEl , 'webkitTransform' , translate3d ) ;
808
- css ( ghostEl , 'mozTransform' , translate3d ) ;
809
- css ( ghostEl , 'msTransform' , translate3d ) ;
810
- css ( ghostEl , 'transform' , translate3d ) ;
834
+ lastDx = dx ;
835
+ lastDy = dy ;
836
+
837
+ touchEvt = touch ;
838
+ }
811
839
812
840
evt . cancelable && evt . preventDefault ( ) ;
813
841
}
@@ -866,9 +894,13 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
866
894
css ( ghostEl , 'zIndex' , '100000' ) ;
867
895
css ( ghostEl , 'pointerEvents' , 'none' ) ;
868
896
897
+
869
898
Sortable . ghost = ghostEl ;
870
899
871
900
container . appendChild ( ghostEl ) ;
901
+
902
+ // Set transform-origin
903
+ css ( ghostEl , 'transform-origin' , ( tapDistanceLeft / parseInt ( ghostEl . style . width ) * 100 ) + '% ' + ( tapDistanceTop / parseInt ( ghostEl . style . height ) * 100 ) + '%' ) ;
872
904
}
873
905
} ,
874
906
@@ -1476,7 +1508,9 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
1476
1508
el . checked = true ;
1477
1509
} ) ;
1478
1510
1479
- savedInputChecked . length = 0 ;
1511
+ savedInputChecked . length =
1512
+ lastDx =
1513
+ lastDy = 0 ;
1480
1514
} ,
1481
1515
1482
1516
handleEvent : function ( /**Event*/ evt ) {
0 commit comments