From 047c40045c3636049219f9a8fff00a55fd1d382f Mon Sep 17 00:00:00 2001 From: Lebedev Konstantin Date: Mon, 20 Feb 2017 14:56:14 +0300 Subject: [PATCH] + _revertDragElement --- Sortable.js | 43 ++++++++++++++++++------------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/Sortable.js b/Sortable.js index 476e0d5..ee0be18 100644 --- a/Sortable.js +++ b/Sortable.js @@ -686,14 +686,15 @@ !options.dragoverBubble && evt.stopPropagation(); } - if (dragEl.animated) { - return; - } + // Smart auto-scrolling + _autoScroll(evt, options, this.el); moved = true; // Check base state if ( + _silent || + dragEl.animated || !activeSortable || options.disabled || !(evt.rootEl === void 0 || evt.rootEl === this.el) // touch fallback @@ -719,38 +720,18 @@ } } - target = _closest(evt.target, options.draggable, el); - dragRect = dragEl.getBoundingClientRect(); - if (putSortable !== this) { putSortable = this; isMovingBetweenSortable = true; } - // Smart auto-scrolling - _autoScroll(evt, options, this.el); - - if (_silent) { + if (revert) { + _revertDragElement(activeSortable, canSort); return; } target = _closest(evt.target, options.draggable, el); dragRect = dragEl.getBoundingClientRect(); - putSortable = this; - - if (revert) { - _cloneHide(activeSortable, true); - parentEl = rootEl; // actualization - - if (cloneEl || nextEl) { - rootEl.insertBefore(dragEl, cloneEl || nextEl); - } - else if (!canSort) { - rootEl.appendChild(dragEl); - } - - return; - } if ((el.children.length === 0) || (el.children[0] === ghostEl) || (el === evt.target) && (target = _ghostIsLast(el, evt)) @@ -1321,6 +1302,18 @@ } + function _revertDragElement(activeSortable, canSort) { + _cloneHide(activeSortable, true); + parentEl = rootEl; // actualization + + if (cloneEl || nextEl) { + rootEl.insertBefore(dragEl, cloneEl || nextEl); + } else if (!canSort) { + rootEl.appendChild(dragEl); + } + } + + /** @returns {HTMLElement|false} */ function _ghostIsLast(el, evt) { var lastEl = el.lastElementChild,