|
1 | 1 | /**! |
2 | | - * Sortable 1.15.1 |
| 2 | + * Sortable 1.15.2 |
3 | 3 | * @author RubaXa <[email protected]> |
4 | 4 | * @author owenm <[email protected]> |
5 | 5 | * @license MIT |
|
134 | 134 | throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); |
135 | 135 | } |
136 | 136 |
|
137 | | - var version = "1.15.1"; |
| 137 | + var version = "1.15.2"; |
138 | 138 |
|
139 | 139 | function userAgent(pattern) { |
140 | 140 | if (typeof window !== 'undefined' && window.navigator) { |
|
335 | 335 | }; |
336 | 336 | } |
337 | 337 |
|
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 | | - |
358 | 338 | /** |
359 | 339 | * Checks if a side of an element is scrolled past a side of its parents |
360 | 340 | * @param {HTMLElement} el The element who's side being scrolled out of view is in question |
|
561 | 541 | css(el, 'width', ''); |
562 | 542 | css(el, 'height', ''); |
563 | 543 | } |
| 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 | + } |
564 | 561 | var expando = 'Sortable' + new Date().getTime(); |
565 | 562 |
|
566 | 563 | function AnimationStateManager() { |
|
2253 | 2250 | } |
2254 | 2251 | function _ghostIsFirst(evt, vertical, sortable) { |
2255 | 2252 | 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); |
2257 | 2254 | 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; |
2259 | 2256 | } |
2260 | 2257 | function _ghostIsLast(evt, vertical, sortable) { |
2261 | 2258 | var lastElRect = getRect(lastChild(sortable.el, sortable.options.draggable)); |
2262 | | - var sortableContentRect = getContentRect(sortable.el); |
| 2259 | + var childContainingRect = getChildContainingRectFromElement(sortable.el, sortable.options, ghostEl); |
2263 | 2260 | 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; |
2265 | 2262 | } |
2266 | 2263 | function _getSwapDirection(evt, target, targetRect, vertical, swapThreshold, invertedSwapThreshold, invertSwap, isLastTarget) { |
2267 | 2264 | var mouseOnAxis = vertical ? evt.clientY : evt.clientX, |
|
0 commit comments