From 8ee92ddd32722240343d7e2e53ba27e2b149b1aa Mon Sep 17 00:00:00 2001 From: RubaXa Date: Fri, 19 Dec 2014 17:39:24 +0300 Subject: [PATCH] #185: fixed group & touch --- Sortable.js | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/Sortable.js b/Sortable.js index ea9d522..1db6bb3 100644 --- a/Sortable.js +++ b/Sortable.js @@ -104,9 +104,7 @@ setData: function (dataTransfer, dragEl) { dataTransfer.setData('Text', dragEl.textContent); } - }, - - group = options.group; + }; // Set default options @@ -115,6 +113,8 @@ } + var group = options.group; + if (!group || typeof group != 'object') { group = options.group = { name: group }; } @@ -286,19 +286,29 @@ _css(ghostEl, 'display', 'none'); var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY), - parent = target.parentNode, + parent = target && target.parentNode, groupName = this.options.group.name, i = touchDragOverListeners.length; - if (parent && (' ' + parent[expando] + ' ').indexOf(groupName) > -1) { - while (i--) { - touchDragOverListeners[i]({ - clientX: touchEvt.clientX, - clientY: touchEvt.clientY, - target: target, - rootEl: parent - }); + if (parent) { + do { + if ((' ' + parent[expando] + ' ').indexOf(groupName) > -1) { + while (i--) { + touchDragOverListeners[i]({ + clientX: touchEvt.clientX, + clientY: touchEvt.clientY, + target: target, + rootEl: parent + }); + } + + break; + } + + target = parent; // store last element } + /* jshint boss:true */ + while (parent = parent.parentNode); } _css(ghostEl, 'display', '');