1
1
/**!
2
- * Sortable 1.9.0
2
+ * Sortable 1.10.0-rc1
3
3
* @author RubaXa <[email protected] >
4
4
* @author owenm <[email protected] >
5
5
* @license MIT
@@ -126,7 +126,7 @@ function _nonIterableSpread() {
126
126
throw new TypeError ( "Invalid attempt to spread non-iterable instance" ) ;
127
127
}
128
128
129
- var version = "1.9.0 " ;
129
+ var version = "1.10.0-rc1 " ;
130
130
131
131
function userAgent ( pattern ) {
132
132
return ! ! navigator . userAgent . match ( pattern ) ;
@@ -835,7 +835,8 @@ var PluginManager = {
835
835
836
836
for ( var i in plugins ) {
837
837
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 ) ) ;
839
840
}
840
841
841
842
return eventOptions ;
@@ -1041,6 +1042,15 @@ supportDraggable = 'draggable' in document.createElement('div'),
1041
1042
1042
1043
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' ;
1043
1044
} ,
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
+ } ,
1044
1054
1045
1055
/**
1046
1056
* Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
@@ -1198,7 +1208,7 @@ function Sortable$1(el, options) {
1198
1208
dataIdAttr : 'data-id' ,
1199
1209
delay : 0 ,
1200
1210
delayOnTouchOnly : false ,
1201
- touchStartThreshold : parseInt ( window . devicePixelRatio , 10 ) || 1 ,
1211
+ touchStartThreshold : Number . parseInt ( window . devicePixelRatio , 10 ) || 1 ,
1202
1212
forceFallback : false ,
1203
1213
fallbackClass : 'sortable-fallback' ,
1204
1214
fallbackOnBody : false ,
@@ -1785,7 +1795,7 @@ Sortable$1.prototype =
1785
1795
target : target ,
1786
1796
completed : completed ,
1787
1797
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 ) ;
1789
1799
} ,
1790
1800
changed : changed
1791
1801
} , extra ) ) ;
@@ -1943,20 +1953,22 @@ Sortable$1.prototype =
1943
1953
return completed ( true ) ;
1944
1954
}
1945
1955
} else if ( target . parentNode === el ) {
1956
+ targetRect = getRect ( target ) ;
1946
1957
var direction = 0 ,
1947
1958
targetBeforeFirstSwap ,
1948
1959
differentLevel = dragEl . parentNode !== el ,
1960
+ differentRowCol = ! _dragElInRowColumn ( dragEl . animated && dragEl . toRect || dragRect , target . animated && target . toRect || targetRect , vertical ) ,
1949
1961
side1 = vertical ? 'top' : 'left' ,
1950
1962
scrolledPastTop = isScrolledPast ( target , null , 'top' , 'top' ) || isScrolledPast ( dragEl , null , 'top' , 'top' ) ,
1951
1963
scrollBefore = scrolledPastTop ? scrolledPastTop . scrollTop : void 0 ;
1952
1964
1953
1965
if ( lastTarget !== target ) {
1954
- targetBeforeFirstSwap = getRect ( target ) [ side1 ] ;
1966
+ targetBeforeFirstSwap = targetRect [ side1 ] ;
1955
1967
pastFirstInvertThresh = false ;
1956
- isCircumstantialInvert = options . invertSwap || differentLevel ;
1968
+ isCircumstantialInvert = ! differentRowCol && options . invertSwap || differentLevel ;
1957
1969
}
1958
1970
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 ) ;
1960
1972
var sibling ;
1961
1973
1962
1974
if ( direction !== 0 ) {
@@ -1976,7 +1988,6 @@ Sortable$1.prototype =
1976
1988
1977
1989
lastTarget = target ;
1978
1990
lastDirection = direction ;
1979
- targetRect = getRect ( target ) ;
1980
1991
var nextSibling = target . nextElementSibling ,
1981
1992
after = false ;
1982
1993
after = direction === 1 ;
@@ -2445,13 +2456,9 @@ function _unsilent() {
2445
2456
}
2446
2457
2447
2458
function _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 ;
2455
2462
}
2456
2463
2457
2464
function _getSwapDirection ( evt , target , vertical , swapThreshold , invertedSwapThreshold , invertSwap , isLastTarget ) {
@@ -3534,9 +3541,36 @@ function MultiDragPlugin() {
3534
3541
}
3535
3542
} ,
3536
3543
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
+ } ) ;
3537
3569
return {
3538
3570
items : _toConsumableArray ( multiDragElements ) ,
3539
- clones : [ ] . concat ( multiDragClones )
3571
+ clones : [ ] . concat ( multiDragClones ) ,
3572
+ oldIndicies : oldIndicies ,
3573
+ newIndicies : newIndicies
3540
3574
} ;
3541
3575
} ,
3542
3576
optionListeners : {
0 commit comments