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