From a4e003d4dfe1e9f2b718df57e61d4b8d3fcb163a Mon Sep 17 00:00:00 2001 From: Cyril Auburtin Date: Mon, 26 Oct 2015 22:43:04 +0100 Subject: [PATCH] avoid changing oldIndex by the parent container should fix #618 and #597 oldIndex was changed first by with the item being dragged, but also by the drag event of the parent (which should be avoided when we are not using the drag-handle) --- Sortable.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Sortable.js b/Sortable.js index 7078104..45bc769 100644 --- a/Sortable.js +++ b/Sortable.js @@ -269,6 +269,10 @@ if (!target) { return; } + + if (options.handle && !_closest(originalTarget, options.handle, el)) { + return; + } // get the index of the dragged element within its parent oldIndex = _index(target); @@ -297,12 +301,6 @@ } } - - if (options.handle && !_closest(originalTarget, options.handle, el)) { - return; - } - - // Prepare `dragstart` this._prepareDragStart(evt, touch, target); },