|
|
|
@ -310,7 +310,7 @@
|
|
|
|
|
type = evt.type, |
|
|
|
|
touch = evt.touches && evt.touches[0], |
|
|
|
|
target = (touch || evt).target, |
|
|
|
|
originalTarget = evt.target.shadowRoot && evt.path[0] || target, |
|
|
|
|
originalTarget = evt.target.shadowRoot && (evt.path && evt.path[0]) || target, |
|
|
|
|
filter = options.filter, |
|
|
|
|
startIndex; |
|
|
|
|
|
|
|
|
@ -322,7 +322,7 @@
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (type === 'mousedown' && evt.button !== 0 || options.disabled) { |
|
|
|
|
if (/mousedown|pointerdown/.test(type) && evt.button !== 0 || options.disabled) { |
|
|
|
|
return; // only left button or enabled
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -479,11 +479,11 @@
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
if (document.selection) {
|
|
|
|
|
// Timeout neccessary for IE9
|
|
|
|
|
if (document.selection) { |
|
|
|
|
// Timeout neccessary for IE9
|
|
|
|
|
setTimeout(function () { |
|
|
|
|
document.selection.empty(); |
|
|
|
|
});
|
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
window.getSelection().removeAllRanges(); |
|
|
|
|
} |
|
|
|
@ -736,8 +736,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ((el.children.length === 0) || (el.children[0] === ghostEl) || |
|
|
|
|
(el === evt.target) && (target = _ghostIsLast(el, evt)) |
|
|
|
|
(el === evt.target) && (_ghostIsLast(el, evt)) |
|
|
|
|
) { |
|
|
|
|
//assign target only if condition is true
|
|
|
|
|
if (el.children.length !== 0 && el.children[0] !== ghostEl && el === evt.target) { |
|
|
|
|
target = el.lastElementChild; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (target) { |
|
|
|
|
if (target.animated) { |
|
|
|
|
return; |
|
|
|
@ -775,34 +780,36 @@
|
|
|
|
|
isLong = (target.offsetHeight > dragEl.offsetHeight), |
|
|
|
|
halfway = (floating ? (evt.clientX - targetRect.left) / width : (evt.clientY - targetRect.top) / height) > 0.5, |
|
|
|
|
nextSibling = target.nextElementSibling, |
|
|
|
|
moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt), |
|
|
|
|
after = false |
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
if (moveVector !== false) { |
|
|
|
|
_silent = true; |
|
|
|
|
setTimeout(_unsilent, 30); |
|
|
|
|
if (floating) { |
|
|
|
|
var elTop = dragEl.offsetTop, |
|
|
|
|
tgTop = target.offsetTop; |
|
|
|
|
|
|
|
|
|
_cloneHide(activeSortable, isOwner); |
|
|
|
|
if (elTop === tgTop) { |
|
|
|
|
after = (target.previousElementSibling === dragEl) && !isWide || halfway && isWide; |
|
|
|
|
} |
|
|
|
|
else if (target.previousElementSibling === dragEl || dragEl.previousElementSibling === target) { |
|
|
|
|
after = (evt.clientY - targetRect.top) / height > 0.5; |
|
|
|
|
} else { |
|
|
|
|
after = tgTop > elTop; |
|
|
|
|
} |
|
|
|
|
} else if (!isMovingBetweenSortable) { |
|
|
|
|
after = (nextSibling !== dragEl) && !isLong || halfway && isLong; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var moveVector = _onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt, after); |
|
|
|
|
|
|
|
|
|
if (moveVector !== false) { |
|
|
|
|
if (moveVector === 1 || moveVector === -1) { |
|
|
|
|
after = (moveVector === 1); |
|
|
|
|
} |
|
|
|
|
else if (floating) { |
|
|
|
|
var elTop = dragEl.offsetTop, |
|
|
|
|
tgTop = target.offsetTop; |
|
|
|
|
|
|
|
|
|
if (elTop === tgTop) { |
|
|
|
|
after = (target.previousElementSibling === dragEl) && !isWide || halfway && isWide; |
|
|
|
|
} |
|
|
|
|
else if (target.previousElementSibling === dragEl || dragEl.previousElementSibling === target) { |
|
|
|
|
after = (evt.clientY - targetRect.top) / height > 0.5; |
|
|
|
|
} else { |
|
|
|
|
after = tgTop > elTop; |
|
|
|
|
} |
|
|
|
|
} else if (!isMovingBetweenSortable) { |
|
|
|
|
after = (nextSibling !== dragEl) && !isLong || halfway && isLong; |
|
|
|
|
} |
|
|
|
|
_silent = true; |
|
|
|
|
setTimeout(_unsilent, 30); |
|
|
|
|
|
|
|
|
|
_cloneHide(activeSortable, isOwner); |
|
|
|
|
|
|
|
|
|
if (!dragEl.contains(el)) { |
|
|
|
|
if (after && !nextSibling) { |
|
|
|
@ -860,6 +867,7 @@
|
|
|
|
|
_off(ownerDocument, 'touchend', this._onDrop); |
|
|
|
|
_off(ownerDocument, 'pointerup', this._onDrop); |
|
|
|
|
_off(ownerDocument, 'touchcancel', this._onDrop); |
|
|
|
|
_off(ownerDocument, 'pointercancel', this._onDrop); |
|
|
|
|
_off(ownerDocument, 'selectstart', this); |
|
|
|
|
}, |
|
|
|
|
|
|
|
|
@ -887,7 +895,12 @@
|
|
|
|
|
!options.dropBubble && evt.stopPropagation(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ghostEl && ghostEl.parentNode.removeChild(ghostEl); |
|
|
|
|
ghostEl && ghostEl.parentNode && ghostEl.parentNode.removeChild(ghostEl); |
|
|
|
|
|
|
|
|
|
if (rootEl === parentEl || Sortable.active.lastPullMode !== 'clone') { |
|
|
|
|
// Remove clone
|
|
|
|
|
cloneEl && cloneEl.parentNode && cloneEl.parentNode.removeChild(cloneEl); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (dragEl) { |
|
|
|
|
if (this.nativeDraggable) { |
|
|
|
@ -901,11 +914,13 @@
|
|
|
|
|
_toggleClass(dragEl, this.options.ghostClass, false); |
|
|
|
|
_toggleClass(dragEl, this.options.chosenClass, false); |
|
|
|
|
|
|
|
|
|
// Drag stop event
|
|
|
|
|
_dispatchEvent(this, rootEl, 'unchoose', dragEl, rootEl, oldIndex); |
|
|
|
|
|
|
|
|
|
if (rootEl !== parentEl) { |
|
|
|
|
newIndex = _index(dragEl, options.draggable); |
|
|
|
|
|
|
|
|
|
if (newIndex >= 0) { |
|
|
|
|
|
|
|
|
|
// Add event
|
|
|
|
|
_dispatchEvent(null, parentEl, 'add', dragEl, rootEl, oldIndex, newIndex); |
|
|
|
|
|
|
|
|
@ -918,9 +933,6 @@
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
else { |
|
|
|
|
// Remove clone
|
|
|
|
|
cloneEl && cloneEl.parentNode.removeChild(cloneEl); |
|
|
|
|
|
|
|
|
|
if (dragEl.nextSibling !== nextEl) { |
|
|
|
|
// Get the index of the dragged element within its parent
|
|
|
|
|
newIndex = _index(dragEl, options.draggable); |
|
|
|
@ -1269,7 +1281,7 @@
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvt) { |
|
|
|
|
function _onMove(fromEl, toEl, dragEl, dragRect, targetEl, targetRect, originalEvt, willInsertAfter) { |
|
|
|
|
var evt, |
|
|
|
|
sortable = fromEl[expando], |
|
|
|
|
onMoveFn = sortable.options.onMove, |
|
|
|
@ -1284,6 +1296,7 @@
|
|
|
|
|
evt.draggedRect = dragRect; |
|
|
|
|
evt.related = targetEl || toEl; |
|
|
|
|
evt.relatedRect = targetRect || toEl.getBoundingClientRect(); |
|
|
|
|
evt.willInsertAfter = willInsertAfter; |
|
|
|
|
|
|
|
|
|
fromEl.dispatchEvent(evt); |
|
|
|
|
|
|
|
|
@ -1312,10 +1325,8 @@
|
|
|
|
|
|
|
|
|
|
// 5 — min delta
|
|
|
|
|
// abs — нельзя добавлять, а то глюки при наведении сверху
|
|
|
|
|
return ( |
|
|
|
|
(evt.clientY - (rect.top + rect.height) > 5) || |
|
|
|
|
(evt.clientX - (rect.right + rect.width) > 5) |
|
|
|
|
) && lastEl; |
|
|
|
|
return (evt.clientY - (rect.top + rect.height) > 5) || |
|
|
|
|
(evt.clientX - (rect.left + rect.width) > 5); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -1475,6 +1486,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Export
|
|
|
|
|
Sortable.version = '1.5.0'; |
|
|
|
|
Sortable.version = '1.6.1'; |
|
|
|
|
return Sortable; |
|
|
|
|
}); |
|
|
|
|