11/**!
2- * Sortable 1.9.0
2+ * Sortable 1.10.0-rc1
33 * @author RubaXa <[email protected] > 44 * @author owenm <[email protected] > 55 * @license MIT
@@ -126,7 +126,7 @@ function _nonIterableSpread() {
126126 throw new TypeError ( "Invalid attempt to spread non-iterable instance" ) ;
127127}
128128
129- var version = "1.9.0 " ;
129+ var version = "1.10.0-rc1 " ;
130130
131131function userAgent ( pattern ) {
132132 return ! ! navigator . userAgent . match ( pattern ) ;
@@ -835,7 +835,8 @@ var PluginManager = {
835835
836836 for ( var i in plugins ) {
837837 if ( typeof plugins [ i ] . eventOptions !== 'function' ) continue ;
838- eventOptions = _objectSpread ( { } , eventOptions , plugins [ i ] . eventOptions ( name , sortable ) ) ;
838+
839+ _extends ( eventOptions , plugins [ i ] . eventOptions . call ( sortable , name ) ) ;
839840 }
840841
841842 return eventOptions ;
@@ -1041,6 +1042,15 @@ supportDraggable = 'draggable' in document.createElement('div'),
10411042
10421043 return child1 && ( firstChildCSS . display === 'block' || firstChildCSS . display === 'flex' || firstChildCSS . display === 'table' || firstChildCSS . display === 'grid' || firstChildWidth >= elWidth && elCSS [ CSSFloatProperty ] === 'none' || child2 && elCSS [ CSSFloatProperty ] === 'none' && firstChildWidth + secondChildWidth > elWidth ) ? 'vertical' : 'horizontal' ;
10431044} ,
1045+ _dragElInRowColumn = function _dragElInRowColumn ( dragRect , targetRect , vertical ) {
1046+ var dragElS1Opp = vertical ? dragRect . left : dragRect . top ,
1047+ dragElS2Opp = vertical ? dragRect . right : dragRect . bottom ,
1048+ dragElOppLength = vertical ? dragRect . width : dragRect . height ,
1049+ targetS1Opp = vertical ? targetRect . left : targetRect . top ,
1050+ targetS2Opp = vertical ? targetRect . right : targetRect . bottom ,
1051+ targetOppLength = vertical ? targetRect . width : targetRect . height ;
1052+ return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2 ;
1053+ } ,
10441054
10451055/**
10461056 * Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
@@ -1198,7 +1208,7 @@ function Sortable$1(el, options) {
11981208 dataIdAttr : 'data-id' ,
11991209 delay : 0 ,
12001210 delayOnTouchOnly : false ,
1201- touchStartThreshold : parseInt ( window . devicePixelRatio , 10 ) || 1 ,
1211+ touchStartThreshold : Number . parseInt ( window . devicePixelRatio , 10 ) || 1 ,
12021212 forceFallback : false ,
12031213 fallbackClass : 'sortable-fallback' ,
12041214 fallbackOnBody : false ,
@@ -1785,7 +1795,7 @@ Sortable$1.prototype =
17851795 target : target ,
17861796 completed : completed ,
17871797 onMove : function onMove ( target , after ) {
1788- _onMove ( rootEl , el , dragEl , dragRect , target , getRect ( target ) , evt , after ) ;
1798+ return _onMove ( rootEl , el , dragEl , dragRect , target , getRect ( target ) , evt , after ) ;
17891799 } ,
17901800 changed : changed
17911801 } , extra ) ) ;
@@ -1943,20 +1953,22 @@ Sortable$1.prototype =
19431953 return completed ( true ) ;
19441954 }
19451955 } else if ( target . parentNode === el ) {
1956+ targetRect = getRect ( target ) ;
19461957 var direction = 0 ,
19471958 targetBeforeFirstSwap ,
19481959 differentLevel = dragEl . parentNode !== el ,
1960+ differentRowCol = ! _dragElInRowColumn ( dragEl . animated && dragEl . toRect || dragRect , target . animated && target . toRect || targetRect , vertical ) ,
19491961 side1 = vertical ? 'top' : 'left' ,
19501962 scrolledPastTop = isScrolledPast ( target , null , 'top' , 'top' ) || isScrolledPast ( dragEl , null , 'top' , 'top' ) ,
19511963 scrollBefore = scrolledPastTop ? scrolledPastTop . scrollTop : void 0 ;
19521964
19531965 if ( lastTarget !== target ) {
1954- targetBeforeFirstSwap = getRect ( target ) [ side1 ] ;
1966+ targetBeforeFirstSwap = targetRect [ side1 ] ;
19551967 pastFirstInvertThresh = false ;
1956- isCircumstantialInvert = options . invertSwap || differentLevel ;
1968+ isCircumstantialInvert = ! differentRowCol && options . invertSwap || differentLevel ;
19571969 }
19581970
1959- direction = _getSwapDirection ( evt , target , vertical , options . swapThreshold , options . invertedSwapThreshold == null ? options . swapThreshold : options . invertedSwapThreshold , isCircumstantialInvert , lastTarget === target ) ;
1971+ direction = _getSwapDirection ( evt , target , vertical , differentRowCol ? 1 : options . swapThreshold , options . invertedSwapThreshold == null ? options . swapThreshold : options . invertedSwapThreshold , isCircumstantialInvert , lastTarget === target ) ;
19601972 var sibling ;
19611973
19621974 if ( direction !== 0 ) {
@@ -1976,7 +1988,6 @@ Sortable$1.prototype =
19761988
19771989 lastTarget = target ;
19781990 lastDirection = direction ;
1979- targetRect = getRect ( target ) ;
19801991 var nextSibling = target . nextElementSibling ,
19811992 after = false ;
19821993 after = direction === 1 ;
@@ -2445,13 +2456,9 @@ function _unsilent() {
24452456}
24462457
24472458function _ghostIsLast ( evt , vertical , sortable ) {
2448- var elRect = getRect ( lastChild ( sortable . el , sortable . options . draggable ) ) ,
2449- mouseOnAxis = vertical ? evt . clientY : evt . clientX ,
2450- mouseOnOppAxis = vertical ? evt . clientX : evt . clientY ,
2451- targetS2 = vertical ? elRect . bottom : elRect . right ,
2452- targetS1Opp = vertical ? elRect . left : elRect . top ,
2453- targetS2Opp = vertical ? elRect . right : elRect . bottom ;
2454- return mouseOnAxis > targetS2 && mouseOnOppAxis > targetS1Opp && mouseOnOppAxis < targetS2Opp ;
2459+ var rect = getRect ( lastChild ( sortable . el , sortable . options . draggable ) ) ;
2460+ var spacer = 10 ;
2461+ return vertical ? evt . clientX > rect . right + spacer || evt . clientX <= rect . right && evt . clientY > rect . bottom && evt . clientX >= rect . left : evt . clientX > rect . right && evt . clientY > rect . top || evt . clientX <= rect . right && evt . clientY > rect . bottom + spacer ;
24552462}
24562463
24572464function _getSwapDirection ( evt , target , vertical , swapThreshold , invertedSwapThreshold , invertSwap , isLastTarget ) {
@@ -3534,9 +3541,36 @@ function MultiDragPlugin() {
35343541 }
35353542 } ,
35363543 eventOptions : function eventOptions ( ) {
3544+ var _this = this ;
3545+
3546+ var oldIndicies = [ ] ,
3547+ newIndicies = [ ] ;
3548+ multiDragElements . forEach ( function ( element ) {
3549+ oldIndicies . push ( {
3550+ element : element ,
3551+ index : element . sortableIndex
3552+ } ) ; // multiDragElements will already be sorted if folding
3553+
3554+ var newIndex ;
3555+
3556+ if ( folding && element !== dragEl$1 ) {
3557+ newIndex = - 1 ;
3558+ } else if ( folding ) {
3559+ newIndex = index ( element , ':not(.' + _this . options . selectedClass + ')' ) ;
3560+ } else {
3561+ newIndex = index ( element ) ;
3562+ }
3563+
3564+ newIndicies . push ( {
3565+ element : element ,
3566+ index : newIndex
3567+ } ) ;
3568+ } ) ;
35373569 return {
35383570 items : _toConsumableArray ( multiDragElements ) ,
3539- clones : [ ] . concat ( multiDragClones )
3571+ clones : [ ] . concat ( multiDragClones ) ,
3572+ oldIndicies : oldIndicies ,
3573+ newIndicies : newIndicies
35403574 } ;
35413575 } ,
35423576 optionListeners : {
0 commit comments