Browse Source

#185: fixed group & touch

pull/191/head
RubaXa 10 years ago
parent
commit
8ee92ddd32
  1. 34
      Sortable.js

34
Sortable.js

@ -104,9 +104,7 @@
setData: function (dataTransfer, dragEl) { setData: function (dataTransfer, dragEl) {
dataTransfer.setData('Text', dragEl.textContent); dataTransfer.setData('Text', dragEl.textContent);
} }
}, };
group = options.group;
// Set default options // Set default options
@ -115,6 +113,8 @@
} }
var group = options.group;
if (!group || typeof group != 'object') { if (!group || typeof group != 'object') {
group = options.group = { name: group }; group = options.group = { name: group };
} }
@ -286,19 +286,29 @@
_css(ghostEl, 'display', 'none'); _css(ghostEl, 'display', 'none');
var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY), var target = document.elementFromPoint(touchEvt.clientX, touchEvt.clientY),
parent = target.parentNode, parent = target && target.parentNode,
groupName = this.options.group.name, groupName = this.options.group.name,
i = touchDragOverListeners.length; i = touchDragOverListeners.length;
if (parent && (' ' + parent[expando] + ' ').indexOf(groupName) > -1) { if (parent) {
while (i--) { do {
touchDragOverListeners[i]({ if ((' ' + parent[expando] + ' ').indexOf(groupName) > -1) {
clientX: touchEvt.clientX, while (i--) {
clientY: touchEvt.clientY, touchDragOverListeners[i]({
target: target, clientX: touchEvt.clientX,
rootEl: parent clientY: touchEvt.clientY,
}); target: target,
rootEl: parent
});
}
break;
}
target = parent; // store last element
} }
/* jshint boss:true */
while (parent = parent.parentNode);
} }
_css(ghostEl, 'display', ''); _css(ghostEl, 'display', '');

Loading…
Cancel
Save