Browse Source

Merge branch 'dev' of github.com:RubaXa/Sortable into dev

pull/564/head
RubaXa 9 years ago
parent
commit
72c62eab60
  1. 24
      Sortable.js
  2. 4
      Sortable.min.js
  3. 2
      component.json
  4. 2
      package.json

24
Sortable.js

@ -767,7 +767,7 @@
if (rootEl !== parentEl) { if (rootEl !== parentEl) {
newIndex = _index(dragEl); newIndex = _index(dragEl);
if (newIndex != -1) { if (newIndex >= 0) {
// drag from one list and drop into another // drag from one list and drop into another
_dispatchEvent(null, parentEl, 'sort', dragEl, rootEl, oldIndex, newIndex); _dispatchEvent(null, parentEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
_dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex); _dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
@ -786,7 +786,8 @@
if (dragEl.nextSibling !== nextEl) { if (dragEl.nextSibling !== nextEl) {
// Get the index of the dragged element within its parent // Get the index of the dragged element within its parent
newIndex = _index(dragEl); newIndex = _index(dragEl);
if (newIndex != -1) {
if (newIndex >= 0) {
// drag & drop within the same list // drag & drop within the same list
_dispatchEvent(this, rootEl, 'update', dragEl, rootEl, oldIndex, newIndex); _dispatchEvent(this, rootEl, 'update', dragEl, rootEl, oldIndex, newIndex);
_dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex); _dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
@ -795,7 +796,10 @@
} }
if (Sortable.active) { if (Sortable.active) {
// Drag end event if (newIndex === null || newIndex === -1) {
newIndex = oldIndex;
}
_dispatchEvent(this, rootEl, 'end', dragEl, rootEl, oldIndex, newIndex); _dispatchEvent(this, rootEl, 'end', dragEl, rootEl, oldIndex, newIndex);
// Save sorting // Save sorting
@ -1158,20 +1162,22 @@
/** /**
* Returns the index of an element within its parent * Returns the index of an element within its parent
* @param el * @param {HTMLElement} el
* @returns {number} * @return {number}
* @private
*/ */
function _index(/**HTMLElement*/el) { function _index(el) {
var index = 0;
if (!el || !el.parentNode) { if (!el || !el.parentNode) {
return -1; return -1;
} }
var index = 0;
while (el && (el = el.previousElementSibling)) { while (el && (el = el.previousElementSibling)) {
if (el.nodeName.toUpperCase() !== 'TEMPLATE') { if (el.nodeName.toUpperCase() !== 'TEMPLATE') {
index++; index++;
} }
} }
return index; return index;
} }
@ -1237,6 +1243,6 @@
// Export // Export
Sortable.version = '1.3.0-rc1'; Sortable.version = '1.3.0-rc2';
return Sortable; return Sortable;
}); });

4
Sortable.min.js vendored

File diff suppressed because one or more lines are too long

2
component.json

@ -1,7 +1,7 @@
{ {
"name": "Sortable", "name": "Sortable",
"main": "Sortable.js", "main": "Sortable.js",
"version": "1.3.0-rc1", "version": "1.3.0-rc2",
"homepage": "http://rubaxa.github.io/Sortable/", "homepage": "http://rubaxa.github.io/Sortable/",
"repo": "RubaXa/Sortable", "repo": "RubaXa/Sortable",
"authors": [ "authors": [

2
package.json

@ -1,7 +1,7 @@
{ {
"name": "sortablejs", "name": "sortablejs",
"exportName": "Sortable", "exportName": "Sortable",
"version": "1.3.0-rc1", "version": "1.3.0-rc2",
"devDependencies": { "devDependencies": {
"grunt": "*", "grunt": "*",
"grunt-version": "*", "grunt-version": "*",

Loading…
Cancel
Save