Skip to content

Commit 5c0a7ec

Browse files
committed
1.10.0-rc1
1 parent 3a3f4e1 commit 5c0a7ec

7 files changed

+209
-105
lines changed

Sortable.js

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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
@@ -132,7 +132,7 @@
132132
throw new TypeError("Invalid attempt to spread non-iterable instance");
133133
}
134134

135-
var version = "1.9.0";
135+
var version = "1.10.0-rc1";
136136

137137
function userAgent(pattern) {
138138
return !!navigator.userAgent.match(pattern);
@@ -841,7 +841,8 @@
841841

842842
for (var i in plugins) {
843843
if (typeof plugins[i].eventOptions !== 'function') continue;
844-
eventOptions = _objectSpread({}, eventOptions, plugins[i].eventOptions(name, sortable));
844+
845+
_extends(eventOptions, plugins[i].eventOptions.call(sortable, name));
845846
}
846847

847848
return eventOptions;
@@ -1047,6 +1048,15 @@
10471048

10481049
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';
10491050
},
1051+
_dragElInRowColumn = function _dragElInRowColumn(dragRect, targetRect, vertical) {
1052+
var dragElS1Opp = vertical ? dragRect.left : dragRect.top,
1053+
dragElS2Opp = vertical ? dragRect.right : dragRect.bottom,
1054+
dragElOppLength = vertical ? dragRect.width : dragRect.height,
1055+
targetS1Opp = vertical ? targetRect.left : targetRect.top,
1056+
targetS2Opp = vertical ? targetRect.right : targetRect.bottom,
1057+
targetOppLength = vertical ? targetRect.width : targetRect.height;
1058+
return dragElS1Opp === targetS1Opp || dragElS2Opp === targetS2Opp || dragElS1Opp + dragElOppLength / 2 === targetS1Opp + targetOppLength / 2;
1059+
},
10501060

10511061
/**
10521062
* Detects first nearest empty sortable to X and Y position using emptyInsertThreshold.
@@ -1204,7 +1214,7 @@
12041214
dataIdAttr: 'data-id',
12051215
delay: 0,
12061216
delayOnTouchOnly: false,
1207-
touchStartThreshold: parseInt(window.devicePixelRatio, 10) || 1,
1217+
touchStartThreshold: Number.parseInt(window.devicePixelRatio, 10) || 1,
12081218
forceFallback: false,
12091219
fallbackClass: 'sortable-fallback',
12101220
fallbackOnBody: false,
@@ -1791,7 +1801,7 @@
17911801
target: target,
17921802
completed: completed,
17931803
onMove: function onMove(target, after) {
1794-
_onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
1804+
return _onMove(rootEl, el, dragEl, dragRect, target, getRect(target), evt, after);
17951805
},
17961806
changed: changed
17971807
}, extra));
@@ -1949,20 +1959,22 @@
19491959
return completed(true);
19501960
}
19511961
} else if (target.parentNode === el) {
1962+
targetRect = getRect(target);
19521963
var direction = 0,
19531964
targetBeforeFirstSwap,
19541965
differentLevel = dragEl.parentNode !== el,
1966+
differentRowCol = !_dragElInRowColumn(dragEl.animated && dragEl.toRect || dragRect, target.animated && target.toRect || targetRect, vertical),
19551967
side1 = vertical ? 'top' : 'left',
19561968
scrolledPastTop = isScrolledPast(target, null, 'top', 'top') || isScrolledPast(dragEl, null, 'top', 'top'),
19571969
scrollBefore = scrolledPastTop ? scrolledPastTop.scrollTop : void 0;
19581970

19591971
if (lastTarget !== target) {
1960-
targetBeforeFirstSwap = getRect(target)[side1];
1972+
targetBeforeFirstSwap = targetRect[side1];
19611973
pastFirstInvertThresh = false;
1962-
isCircumstantialInvert = options.invertSwap || differentLevel;
1974+
isCircumstantialInvert = !differentRowCol && options.invertSwap || differentLevel;
19631975
}
19641976

1965-
direction = _getSwapDirection(evt, target, vertical, options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
1977+
direction = _getSwapDirection(evt, target, vertical, differentRowCol ? 1 : options.swapThreshold, options.invertedSwapThreshold == null ? options.swapThreshold : options.invertedSwapThreshold, isCircumstantialInvert, lastTarget === target);
19661978
var sibling;
19671979

19681980
if (direction !== 0) {
@@ -1982,7 +1994,6 @@
19821994

19831995
lastTarget = target;
19841996
lastDirection = direction;
1985-
targetRect = getRect(target);
19861997
var nextSibling = target.nextElementSibling,
19871998
after = false;
19881999
after = direction === 1;
@@ -2451,13 +2462,9 @@
24512462
}
24522463

24532464
function _ghostIsLast(evt, vertical, sortable) {
2454-
var elRect = getRect(lastChild(sortable.el, sortable.options.draggable)),
2455-
mouseOnAxis = vertical ? evt.clientY : evt.clientX,
2456-
mouseOnOppAxis = vertical ? evt.clientX : evt.clientY,
2457-
targetS2 = vertical ? elRect.bottom : elRect.right,
2458-
targetS1Opp = vertical ? elRect.left : elRect.top,
2459-
targetS2Opp = vertical ? elRect.right : elRect.bottom;
2460-
return mouseOnAxis > targetS2 && mouseOnOppAxis > targetS1Opp && mouseOnOppAxis < targetS2Opp;
2465+
var rect = getRect(lastChild(sortable.el, sortable.options.draggable));
2466+
var spacer = 10;
2467+
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;
24612468
}
24622469

24632470
function _getSwapDirection(evt, target, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
@@ -3540,9 +3547,36 @@
35403547
}
35413548
},
35423549
eventOptions: function eventOptions() {
3550+
var _this = this;
3551+
3552+
var oldIndicies = [],
3553+
newIndicies = [];
3554+
multiDragElements.forEach(function (element) {
3555+
oldIndicies.push({
3556+
element: element,
3557+
index: element.sortableIndex
3558+
}); // multiDragElements will already be sorted if folding
3559+
3560+
var newIndex;
3561+
3562+
if (folding && element !== dragEl$1) {
3563+
newIndex = -1;
3564+
} else if (folding) {
3565+
newIndex = index(element, ':not(.' + _this.options.selectedClass + ')');
3566+
} else {
3567+
newIndex = index(element);
3568+
}
3569+
3570+
newIndicies.push({
3571+
element: element,
3572+
index: newIndex
3573+
});
3574+
});
35433575
return {
35443576
items: _toConsumableArray(multiDragElements),
3545-
clones: [].concat(multiDragClones)
3577+
clones: [].concat(multiDragClones),
3578+
oldIndicies: oldIndicies,
3579+
newIndicies: newIndicies
35463580
};
35473581
},
35483582
optionListeners: {

Sortable.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

component.json

Lines changed: 0 additions & 33 deletions
This file was deleted.

modular/sortable.complete.esm.js

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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

131131
function 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

24472458
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;
24552462
}
24562463

24572464
function _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

Comments
 (0)