Skip to content

Commit 07708fa

Browse files
committed
1.15.2
1 parent 38e4d87 commit 07708fa

File tree

6 files changed

+95
-107
lines changed

6 files changed

+95
-107
lines changed

Sortable.js

+23-26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**!
2-
* Sortable 1.15.1
2+
* Sortable 1.15.2
33
* @author RubaXa <[email protected]>
44
* @author owenm <[email protected]>
55
* @license MIT
@@ -134,7 +134,7 @@
134134
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
135135
}
136136

137-
var version = "1.15.1";
137+
var version = "1.15.2";
138138

139139
function userAgent(pattern) {
140140
if (typeof window !== 'undefined' && window.navigator) {
@@ -335,26 +335,6 @@
335335
};
336336
}
337337

338-
/**
339-
* Returns the content rect of the element (bounding rect minus border and padding)
340-
* @param {HTMLElement} el
341-
*/
342-
function getContentRect(el) {
343-
var rect = getRect(el);
344-
var paddingLeft = parseInt(css(el, 'padding-left')),
345-
paddingTop = parseInt(css(el, 'padding-top')),
346-
paddingRight = parseInt(css(el, 'padding-right')),
347-
paddingBottom = parseInt(css(el, 'padding-bottom'));
348-
rect.top += paddingTop + parseInt(css(el, 'border-top-width'));
349-
rect.left += paddingLeft + parseInt(css(el, 'border-left-width'));
350-
// Client Width/Height includes padding only
351-
rect.width = el.clientWidth - paddingLeft - paddingRight;
352-
rect.height = el.clientHeight - paddingTop - paddingBottom;
353-
rect.bottom = rect.top + rect.height;
354-
rect.right = rect.left + rect.width;
355-
return rect;
356-
}
357-
358338
/**
359339
* Checks if a side of an element is scrolled past a side of its parents
360340
* @param {HTMLElement} el The element who's side being scrolled out of view is in question
@@ -561,6 +541,23 @@
561541
css(el, 'width', '');
562542
css(el, 'height', '');
563543
}
544+
function getChildContainingRectFromElement(container, options, ghostEl) {
545+
var rect = {};
546+
Array.from(container.children).forEach(function (child) {
547+
var _rect$left, _rect$top, _rect$right, _rect$bottom;
548+
if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl) return;
549+
var childRect = getRect(child);
550+
rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
551+
rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
552+
rect.right = Math.max((_rect$right = rect.right) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right);
553+
rect.bottom = Math.max((_rect$bottom = rect.bottom) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom);
554+
});
555+
rect.width = rect.right - rect.left;
556+
rect.height = rect.bottom - rect.top;
557+
rect.x = rect.left;
558+
rect.y = rect.top;
559+
return rect;
560+
}
564561
var expando = 'Sortable' + new Date().getTime();
565562

566563
function AnimationStateManager() {
@@ -2253,15 +2250,15 @@
22532250
}
22542251
function _ghostIsFirst(evt, vertical, sortable) {
22552252
var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true));
2256-
var sortableContentRect = getContentRect(sortable.el);
2253+
var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
22572254
var spacer = 10;
2258-
return vertical ? evt.clientX < sortableContentRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < sortableContentRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
2255+
return vertical ? evt.clientX < childContainingRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < childContainingRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
22592256
}
22602257
function _ghostIsLast(evt, vertical, sortable) {
22612258
var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable));
2262-
var sortableContentRect = getContentRect(sortable.el);
2259+
var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
22632260
var spacer = 10;
2264-
return vertical ? evt.clientX > sortableContentRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > sortableContentRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
2261+
return vertical ? evt.clientX > childContainingRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > childContainingRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
22652262
}
22662263
function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
22672264
var mouseOnAxis = vertical ? evt.clientY : evt.clientX,

Sortable.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modular/sortable.complete.esm.js

+23-26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**!
2-
* Sortable 1.15.1
2+
* Sortable 1.15.2
33
* @author RubaXa <[email protected]>
44
* @author owenm <[email protected]>
55
* @license MIT
@@ -128,7 +128,7 @@ function _nonIterableSpread() {
128128
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
129129
}
130130

131-
var version = "1.15.1";
131+
var version = "1.15.2";
132132

133133
function userAgent(pattern) {
134134
if (typeof window !== 'undefined' && window.navigator) {
@@ -329,26 +329,6 @@ function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoS
329329
};
330330
}
331331

332-
/**
333-
* Returns the content rect of the element (bounding rect minus border and padding)
334-
* @param {HTMLElement} el
335-
*/
336-
function getContentRect(el) {
337-
var rect = getRect(el);
338-
var paddingLeft = parseInt(css(el, 'padding-left')),
339-
paddingTop = parseInt(css(el, 'padding-top')),
340-
paddingRight = parseInt(css(el, 'padding-right')),
341-
paddingBottom = parseInt(css(el, 'padding-bottom'));
342-
rect.top += paddingTop + parseInt(css(el, 'border-top-width'));
343-
rect.left += paddingLeft + parseInt(css(el, 'border-left-width'));
344-
// Client Width/Height includes padding only
345-
rect.width = el.clientWidth - paddingLeft - paddingRight;
346-
rect.height = el.clientHeight - paddingTop - paddingBottom;
347-
rect.bottom = rect.top + rect.height;
348-
rect.right = rect.left + rect.width;
349-
return rect;
350-
}
351-
352332
/**
353333
* Checks if a side of an element is scrolled past a side of its parents
354334
* @param {HTMLElement} el The element who's side being scrolled out of view is in question
@@ -555,6 +535,23 @@ function unsetRect(el) {
555535
css(el, 'width', '');
556536
css(el, 'height', '');
557537
}
538+
function getChildContainingRectFromElement(container, options, ghostEl) {
539+
var rect = {};
540+
Array.from(container.children).forEach(function (child) {
541+
var _rect$left, _rect$top, _rect$right, _rect$bottom;
542+
if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl) return;
543+
var childRect = getRect(child);
544+
rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
545+
rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
546+
rect.right = Math.max((_rect$right = rect.right) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right);
547+
rect.bottom = Math.max((_rect$bottom = rect.bottom) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom);
548+
});
549+
rect.width = rect.right - rect.left;
550+
rect.height = rect.bottom - rect.top;
551+
rect.x = rect.left;
552+
rect.y = rect.top;
553+
return rect;
554+
}
558555
var expando = 'Sortable' + new Date().getTime();
559556

560557
function AnimationStateManager() {
@@ -2247,15 +2244,15 @@ function _unsilent() {
22472244
}
22482245
function _ghostIsFirst(evt, vertical, sortable) {
22492246
var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true));
2250-
var sortableContentRect = getContentRect(sortable.el);
2247+
var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
22512248
var spacer = 10;
2252-
return vertical ? evt.clientX < sortableContentRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < sortableContentRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
2249+
return vertical ? evt.clientX < childContainingRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < childContainingRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
22532250
}
22542251
function _ghostIsLast(evt, vertical, sortable) {
22552252
var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable));
2256-
var sortableContentRect = getContentRect(sortable.el);
2253+
var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
22572254
var spacer = 10;
2258-
return vertical ? evt.clientX > sortableContentRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > sortableContentRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
2255+
return vertical ? evt.clientX > childContainingRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > childContainingRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
22592256
}
22602257
function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
22612258
var mouseOnAxis = vertical ? evt.clientY : evt.clientX,

modular/sortable.core.esm.js

+23-26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**!
2-
* Sortable 1.15.1
2+
* Sortable 1.15.2
33
* @author RubaXa <[email protected]>
44
* @author owenm <[email protected]>
55
* @license MIT
@@ -128,7 +128,7 @@ function _nonIterableSpread() {
128128
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
129129
}
130130

131-
var version = "1.15.1";
131+
var version = "1.15.2";
132132

133133
function userAgent(pattern) {
134134
if (typeof window !== 'undefined' && window.navigator) {
@@ -329,26 +329,6 @@ function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoS
329329
};
330330
}
331331

332-
/**
333-
* Returns the content rect of the element (bounding rect minus border and padding)
334-
* @param {HTMLElement} el
335-
*/
336-
function getContentRect(el) {
337-
var rect = getRect(el);
338-
var paddingLeft = parseInt(css(el, 'padding-left')),
339-
paddingTop = parseInt(css(el, 'padding-top')),
340-
paddingRight = parseInt(css(el, 'padding-right')),
341-
paddingBottom = parseInt(css(el, 'padding-bottom'));
342-
rect.top += paddingTop + parseInt(css(el, 'border-top-width'));
343-
rect.left += paddingLeft + parseInt(css(el, 'border-left-width'));
344-
// Client Width/Height includes padding only
345-
rect.width = el.clientWidth - paddingLeft - paddingRight;
346-
rect.height = el.clientHeight - paddingTop - paddingBottom;
347-
rect.bottom = rect.top + rect.height;
348-
rect.right = rect.left + rect.width;
349-
return rect;
350-
}
351-
352332
/**
353333
* Checks if a side of an element is scrolled past a side of its parents
354334
* @param {HTMLElement} el The element who's side being scrolled out of view is in question
@@ -555,6 +535,23 @@ function unsetRect(el) {
555535
css(el, 'width', '');
556536
css(el, 'height', '');
557537
}
538+
function getChildContainingRectFromElement(container, options, ghostEl) {
539+
var rect = {};
540+
Array.from(container.children).forEach(function (child) {
541+
var _rect$left, _rect$top, _rect$right, _rect$bottom;
542+
if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl) return;
543+
var childRect = getRect(child);
544+
rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
545+
rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
546+
rect.right = Math.max((_rect$right = rect.right) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right);
547+
rect.bottom = Math.max((_rect$bottom = rect.bottom) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom);
548+
});
549+
rect.width = rect.right - rect.left;
550+
rect.height = rect.bottom - rect.top;
551+
rect.x = rect.left;
552+
rect.y = rect.top;
553+
return rect;
554+
}
558555
var expando = 'Sortable' + new Date().getTime();
559556

560557
function AnimationStateManager() {
@@ -2247,15 +2244,15 @@ function _unsilent() {
22472244
}
22482245
function _ghostIsFirst(evt, vertical, sortable) {
22492246
var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true));
2250-
var sortableContentRect = getContentRect(sortable.el);
2247+
var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
22512248
var spacer = 10;
2252-
return vertical ? evt.clientX < sortableContentRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < sortableContentRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
2249+
return vertical ? evt.clientX < childContainingRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < childContainingRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
22532250
}
22542251
function _ghostIsLast(evt, vertical, sortable) {
22552252
var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable));
2256-
var sortableContentRect = getContentRect(sortable.el);
2253+
var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
22572254
var spacer = 10;
2258-
return vertical ? evt.clientX > sortableContentRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > sortableContentRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
2255+
return vertical ? evt.clientX > childContainingRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > childContainingRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
22592256
}
22602257
function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
22612258
var mouseOnAxis = vertical ? evt.clientY : evt.clientX,

modular/sortable.esm.js

+23-26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**!
2-
* Sortable 1.15.1
2+
* Sortable 1.15.2
33
* @author RubaXa <[email protected]>
44
* @author owenm <[email protected]>
55
* @license MIT
@@ -128,7 +128,7 @@ function _nonIterableSpread() {
128128
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
129129
}
130130

131-
var version = "1.15.1";
131+
var version = "1.15.2";
132132

133133
function userAgent(pattern) {
134134
if (typeof window !== 'undefined' && window.navigator) {
@@ -329,26 +329,6 @@ function getRect(el, relativeToContainingBlock, relativeToNonStaticParent, undoS
329329
};
330330
}
331331

332-
/**
333-
* Returns the content rect of the element (bounding rect minus border and padding)
334-
* @param {HTMLElement} el
335-
*/
336-
function getContentRect(el) {
337-
var rect = getRect(el);
338-
var paddingLeft = parseInt(css(el, 'padding-left')),
339-
paddingTop = parseInt(css(el, 'padding-top')),
340-
paddingRight = parseInt(css(el, 'padding-right')),
341-
paddingBottom = parseInt(css(el, 'padding-bottom'));
342-
rect.top += paddingTop + parseInt(css(el, 'border-top-width'));
343-
rect.left += paddingLeft + parseInt(css(el, 'border-left-width'));
344-
// Client Width/Height includes padding only
345-
rect.width = el.clientWidth - paddingLeft - paddingRight;
346-
rect.height = el.clientHeight - paddingTop - paddingBottom;
347-
rect.bottom = rect.top + rect.height;
348-
rect.right = rect.left + rect.width;
349-
return rect;
350-
}
351-
352332
/**
353333
* Checks if a side of an element is scrolled past a side of its parents
354334
* @param {HTMLElement} el The element who's side being scrolled out of view is in question
@@ -555,6 +535,23 @@ function unsetRect(el) {
555535
css(el, 'width', '');
556536
css(el, 'height', '');
557537
}
538+
function getChildContainingRectFromElement(container, options, ghostEl) {
539+
var rect = {};
540+
Array.from(container.children).forEach(function (child) {
541+
var _rect$left, _rect$top, _rect$right, _rect$bottom;
542+
if (!closest(child, options.draggable, container, false) || child.animated || child === ghostEl) return;
543+
var childRect = getRect(child);
544+
rect.left = Math.min((_rect$left = rect.left) !== null && _rect$left !== void 0 ? _rect$left : Infinity, childRect.left);
545+
rect.top = Math.min((_rect$top = rect.top) !== null && _rect$top !== void 0 ? _rect$top : Infinity, childRect.top);
546+
rect.right = Math.max((_rect$right = rect.right) !== null && _rect$right !== void 0 ? _rect$right : -Infinity, childRect.right);
547+
rect.bottom = Math.max((_rect$bottom = rect.bottom) !== null && _rect$bottom !== void 0 ? _rect$bottom : -Infinity, childRect.bottom);
548+
});
549+
rect.width = rect.right - rect.left;
550+
rect.height = rect.bottom - rect.top;
551+
rect.x = rect.left;
552+
rect.y = rect.top;
553+
return rect;
554+
}
558555
var expando = 'Sortable' + new Date().getTime();
559556

560557
function AnimationStateManager() {
@@ -2247,15 +2244,15 @@ function _unsilent() {
22472244
}
22482245
function _ghostIsFirst(evt, vertical, sortable) {
22492246
var firstElRect = getRect(getChild(sortable.el, 0, sortable.options, true));
2250-
var sortableContentRect = getContentRect(sortable.el);
2247+
var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
22512248
var spacer = 10;
2252-
return vertical ? evt.clientX < sortableContentRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < sortableContentRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
2249+
return vertical ? evt.clientX < childContainingRect.left - spacer || evt.clientY < firstElRect.top && evt.clientX < firstElRect.right : evt.clientY < childContainingRect.top - spacer || evt.clientY < firstElRect.bottom && evt.clientX < firstElRect.left;
22532250
}
22542251
function _ghostIsLast(evt, vertical, sortable) {
22552252
var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable));
2256-
var sortableContentRect = getContentRect(sortable.el);
2253+
var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl);
22572254
var spacer = 10;
2258-
return vertical ? evt.clientX > sortableContentRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > sortableContentRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
2255+
return vertical ? evt.clientX > childContainingRect.right + spacer || evt.clientY > lastElRect.bottom && evt.clientX > lastElRect.left : evt.clientY > childContainingRect.bottom + spacer || evt.clientX > lastElRect.right && evt.clientY > lastElRect.top;
22592256
}
22602257
function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) {
22612258
var mouseOnAxis = vertical ? evt.clientY : evt.clientX,

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "sortablejs",
33
"exportName": "Sortable",
4-
"version": "1.15.1",
4+
"version": "1.15.2",
55
"devDependencies": {
66
"@babel/core": "^7.4.4",
77
"@babel/plugin-transform-object-assign": "^7.2.0",

0 commit comments

Comments
 (0)