|
|
@ -686,132 +686,137 @@ |
|
|
|
|
|
|
|
|
|
|
|
// Check base state
|
|
|
|
// Check base state
|
|
|
|
if ( |
|
|
|
if ( |
|
|
|
|
|
|
|
!activeSortable || |
|
|
|
options.disabled || |
|
|
|
options.disabled || |
|
|
|
(evt.rootEl != null && evt.rootEl !== this.el) || // touch fallback
|
|
|
|
!(evt.rootEl === void 0 || evt.rootEl === this.el) // touch fallback
|
|
|
|
!activeSortable |
|
|
|
|
|
|
|
) { |
|
|
|
) { |
|
|
|
return; |
|
|
|
return; // exit
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ((isOwner |
|
|
|
// Check access
|
|
|
|
? canSort || (revert = !rootEl.contains(dragEl)) // Reverting item into the original list
|
|
|
|
if (isOwner) { |
|
|
|
: ( |
|
|
|
if (!canSort) { |
|
|
|
putSortable === this || |
|
|
|
// Reverting item into the original list
|
|
|
|
( |
|
|
|
if (rootEl.contains(dragEl)) { |
|
|
|
(activeSortable.lastPullMode = activeGroup.checkPull(this, activeSortable, dragEl, evt)) && |
|
|
|
return; // exit
|
|
|
|
group.checkPut(this, activeSortable, dragEl, evt) |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
// Smart auto-scrolling
|
|
|
|
|
|
|
|
_autoScroll(evt, options, this.el); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_silent) { |
|
|
|
revert = true; |
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else if (putSortable !== this) { |
|
|
|
|
|
|
|
activeSortable.lastPullMode = activeGroup.checkPull(this, activeSortable, dragEl, evt); |
|
|
|
|
|
|
|
|
|
|
|
target = _closest(evt.target, options.draggable, el); |
|
|
|
if (!(activeSortable.lastPullMode || group.checkPut(this, activeSortable, dragEl, evt))) { |
|
|
|
dragRect = dragEl.getBoundingClientRect(); |
|
|
|
return; // exit;
|
|
|
|
putSortable = this; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (revert) { |
|
|
|
// Smart auto-scrolling
|
|
|
|
_cloneHide(activeSortable, true); |
|
|
|
_autoScroll(evt, options, this.el); |
|
|
|
parentEl = rootEl; // actualization
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cloneEl || nextEl) { |
|
|
|
if (_silent) { |
|
|
|
rootEl.insertBefore(dragEl, cloneEl || nextEl); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (!canSort) { |
|
|
|
|
|
|
|
rootEl.appendChild(dragEl); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
target = _closest(evt.target, options.draggable, el); |
|
|
|
} |
|
|
|
dragRect = dragEl.getBoundingClientRect(); |
|
|
|
|
|
|
|
putSortable = this; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (revert) { |
|
|
|
|
|
|
|
_cloneHide(activeSortable, true); |
|
|
|
|
|
|
|
parentEl = rootEl; // actualization
|
|
|
|
|
|
|
|
|
|
|
|
if ((el.children.length === 0) || (el.children[0] === ghostEl) || |
|
|
|
if (cloneEl || nextEl) { |
|
|
|
(el === evt.target) && (target = _ghostIsLast(el, evt)) |
|
|
|
rootEl.insertBefore(dragEl, cloneEl || nextEl); |
|
|
|
) { |
|
|
|
} |
|
|
|
if (target) { |
|
|
|
else if (!canSort) { |
|
|
|
if (target.animated) { |
|
|
|
rootEl.appendChild(dragEl); |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
targetRect = target.getBoundingClientRect(); |
|
|
|
if ((el.children.length === 0) || (el.children[0] === ghostEl) || |
|
|
|
|
|
|
|
(el === evt.target) && (target = _ghostIsLast(el, evt)) |
|
|
|
|
|
|
|
) { |
|
|
|
|
|
|
|
if (target) { |
|
|
|
|
|
|
|
if (target.animated) { |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
_cloneHide(activeSortable, isOwner); |
|
|
|
targetRect = target.getBoundingClientRect(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt) !== false) { |
|
|
|
_cloneHide(activeSortable, isOwner); |
|
|
|
if (!dragEl.contains(el)) { |
|
|
|
|
|
|
|
el.appendChild(dragEl); |
|
|
|
|
|
|
|
parentEl = el; // actualization
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._animate(dragRect, dragEl); |
|
|
|
if (_onMove(rootEl, el, dragEl, dragRect, target, targetRect, evt) !== false) { |
|
|
|
target && this._animate(targetRect, target); |
|
|
|
if (!dragEl.contains(el)) { |
|
|
|
|
|
|
|
el.appendChild(dragEl); |
|
|
|
|
|
|
|
parentEl = el; // actualization
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this._animate(dragRect, dragEl); |
|
|
|
|
|
|
|
target && this._animate(targetRect, target); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (target && !target.animated && target !== dragEl && (target.parentNode[expando] !== void 0)) { |
|
|
|
|
|
|
|
if (lastEl !== target) { |
|
|
|
|
|
|
|
lastEl = target; |
|
|
|
|
|
|
|
lastCSS = _css(target); |
|
|
|
|
|
|
|
lastParentCSS = _css(target.parentNode); |
|
|
|
} |
|
|
|
} |
|
|
|
else if (target && !target.animated && target !== dragEl && (target.parentNode[expando] !== void 0)) { |
|
|
|
|
|
|
|
if (lastEl !== target) { |
|
|
|
|
|
|
|
lastEl = target; |
|
|
|
|
|
|
|
lastCSS = _css(target); |
|
|
|
|
|
|
|
lastParentCSS = _css(target.parentNode); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
targetRect = target.getBoundingClientRect(); |
|
|
|
targetRect = target.getBoundingClientRect(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var width = targetRect.right - targetRect.left, |
|
|
|
|
|
|
|
height = targetRect.bottom - targetRect.top, |
|
|
|
|
|
|
|
floating = /left|right|inline/.test(lastCSS.cssFloat + lastCSS.display) |
|
|
|
|
|
|
|
|| (lastParentCSS.display == 'flex' && lastParentCSS['flex-direction'].indexOf('row') === 0), |
|
|
|
|
|
|
|
isWide = (target.offsetWidth > dragEl.offsetWidth), |
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
var width = targetRect.right - targetRect.left, |
|
|
|
if (moveVector !== false) { |
|
|
|
height = targetRect.bottom - targetRect.top, |
|
|
|
_silent = true; |
|
|
|
floating = /left|right|inline/.test(lastCSS.cssFloat + lastCSS.display) |
|
|
|
setTimeout(_unsilent, 30); |
|
|
|
|| (lastParentCSS.display == 'flex' && lastParentCSS['flex-direction'].indexOf('row') === 0), |
|
|
|
|
|
|
|
isWide = (target.offsetWidth > dragEl.offsetWidth), |
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (moveVector !== false) { |
|
|
|
|
|
|
|
_silent = true; |
|
|
|
|
|
|
|
setTimeout(_unsilent, 30); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_cloneHide(activeSortable, isOwner); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (moveVector === 1 || moveVector === -1) { |
|
|
|
|
|
|
|
after = (moveVector === 1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (floating) { |
|
|
|
|
|
|
|
var elTop = dragEl.offsetTop, |
|
|
|
|
|
|
|
tgTop = target.offsetTop; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (elTop === tgTop) { |
|
|
|
_cloneHide(activeSortable, isOwner); |
|
|
|
after = (target.previousElementSibling === dragEl) && !isWide || halfway && isWide; |
|
|
|
|
|
|
|
} |
|
|
|
if (moveVector === 1 || moveVector === -1) { |
|
|
|
else if (target.previousElementSibling === dragEl || dragEl.previousElementSibling === target) { |
|
|
|
after = (moveVector === 1); |
|
|
|
after = (evt.clientY - targetRect.top) / height > 0.5; |
|
|
|
} |
|
|
|
} else { |
|
|
|
else if (floating) { |
|
|
|
after = tgTop > elTop; |
|
|
|
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 { |
|
|
|
} else { |
|
|
|
after = (nextSibling !== dragEl) && !isLong || halfway && isLong; |
|
|
|
after = tgTop > elTop; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
after = (nextSibling !== dragEl) && !isLong || halfway && isLong; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!dragEl.contains(el)) { |
|
|
|
if (!dragEl.contains(el)) { |
|
|
|
if (after && !nextSibling) { |
|
|
|
if (after && !nextSibling) { |
|
|
|
el.appendChild(dragEl); |
|
|
|
el.appendChild(dragEl); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
target.parentNode.insertBefore(dragEl, after ? nextSibling : target); |
|
|
|
target.parentNode.insertBefore(dragEl, after ? nextSibling : target); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
parentEl = dragEl.parentNode; // actualization
|
|
|
|
parentEl = dragEl.parentNode; // actualization
|
|
|
|
|
|
|
|
|
|
|
|
this._animate(dragRect, dragEl); |
|
|
|
this._animate(dragRect, dragEl); |
|
|
|
this._animate(targetRect, target); |
|
|
|
this._animate(targetRect, target); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|