@@ -120,6 +120,10 @@ let dragEl,
120120
121121 tapEvt ,
122122 touchEvt ,
123+ lastDx ,
124+ lastDy ,
125+ tapDistanceLeft ,
126+ tapDistanceTop ,
123127
124128 moved ,
125129
@@ -548,6 +552,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
548552 el = _this . el ,
549553 options = _this . options ,
550554 ownerDocument = el . ownerDocument ,
555+ dragRect = getRect ( target ) ,
551556 dragStartFn ;
552557
553558 if ( target && ! dragEl && ( target . parentNode === el ) ) {
@@ -566,6 +571,9 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
566571 clientY : ( touch || evt ) . clientY
567572 } ;
568573
574+ tapDistanceLeft = tapEvt . clientX - dragRect . left ;
575+ tapDistanceTop = tapEvt . clientY - dragRect . top ;
576+
569577 this . _lastX = ( touch || evt ) . clientX ;
570578 this . _lastY = ( touch || evt ) . clientY ;
571579
@@ -789,8 +797,7 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
789797 + ( relativeScrollOffset ? ( relativeScrollOffset [ 0 ] - ghostRelativeParentInitialScroll [ 0 ] ) : 0 ) / ( scaleX || 1 ) ,
790798 dy = ( ( touch . clientY - tapEvt . clientY )
791799 + 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 ) ;
794801
795802 // only set the status to dragging, when we are actually dragging
796803 if ( ! Sortable . active && ! awaitingDragStarted ) {
@@ -802,12 +809,33 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
802809 this . _onDragStart ( evt , true ) ;
803810 }
804811
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 ) ;
806833
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+ }
811839
812840 evt . cancelable && evt . preventDefault ( ) ;
813841 }
@@ -866,9 +894,13 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
866894 css ( ghostEl , 'zIndex' , '100000' ) ;
867895 css ( ghostEl , 'pointerEvents' , 'none' ) ;
868896
897+
869898 Sortable . ghost = ghostEl ;
870899
871900 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 ) + '%' ) ;
872904 }
873905 } ,
874906
@@ -1476,7 +1508,9 @@ Sortable.prototype = /** @lends Sortable.prototype */ {
14761508 el . checked = true ;
14771509 } ) ;
14781510
1479- savedInputChecked . length = 0 ;
1511+ savedInputChecked . length =
1512+ lastDx =
1513+ lastDy = 0 ;
14801514 } ,
14811515
14821516 handleEvent : function ( /**Event*/ evt ) {
0 commit comments