diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ef9d5d1..dba0657 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ 1. Try [dev](https://github.com/RubaXa/Sortable/tree/dev/)-branch, perhaps the problem has been solved; 2. [Use the search](https://github.com/RubaXa/Sortable/search?q=problem), maybe already have an answer; - 3. If not found, create example on [jsbin.com](http://jsbin.com/zunibaxada/1/edit?html,js,output) and describe the problem. + 3. If not found, create example on [jsbin.com (draft)](http://jsbin.com/zunibaxada/1/edit?html,js,output) and describe the problem. --- diff --git a/README.md b/README.md index a935ba4..cc767bb 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ You can use any element for the list and its elements, not just `ul`/`li`. Here var sortable = new Sortable(el, { group: "name", // or { name: "...", pull: [true, false, clone], put: [true, false, array] } sort: true, // sorting inside list + delay: 0, // time in milliseconds to define when the sorting should start disabled: false, // Disables the sortable if set to true. store: null, // @see Store animation: 150, // ms, animation speed moving items when sorting, `0` — without animation @@ -140,7 +141,7 @@ You can also define whether lists can give away, give and keep a copy (`clone`), #### `sort` option -Sorting inside list +Sorting inside list. Demo: http://jsbin.com/xizeh/2/edit?html,js,output @@ -148,6 +149,15 @@ Demo: http://jsbin.com/xizeh/2/edit?html,js,output --- +#### `delay` option +Time in milliseconds to define when the sorting should start. + +Demo: http://jsbin.com/xizeh/4/edit?html,js,output + + +--- + + #### `disabled` options Disables the sortable if set to `true`. @@ -205,7 +215,7 @@ Sortable.create(el, { Sortable.create(list, { filter: ".js-remove, .js-edit", onFilter: function (evt) { - var item = el.item, + var item = evt.item, ctrl = evt.target; if (Sortable.utils.is(ctrl, ".js-remove")) { // Click on remove button diff --git a/Sortable.js b/Sortable.js index 6de4e05..cf0b5f0 100644 --- a/Sortable.js +++ b/Sortable.js @@ -991,11 +991,11 @@ evt.oldIndex = startIndex; evt.newIndex = newIndex; + rootEl.dispatchEvent(evt); + if (options[onName]) { options[onName].call(sortable, evt); } - - rootEl.dispatchEvent(evt); } @@ -1035,7 +1035,9 @@ /** @returns {HTMLElement|false} */ function _ghostInBottom(el, evt) { - var lastEl = el.lastElementChild, rect = lastEl.getBoundingClientRect(); + var lastEl = el.lastElementChild, + rect = lastEl.getBoundingClientRect(); + return (evt.clientY - (rect.top + rect.height) > 5) && lastEl; // min delta } diff --git a/bower.json b/bower.json index 4ae98d7..741a052 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,11 @@ { "name": "Sortable", - "main": "Sortable.js", + "main": [ + "Sortable.js", + "ng-sortable.js", + "knockout-sortable.js", + "react-sortable-mixin.js" + ], "version": "1.2.0", "homepage": "http://rubaxa.github.io/Sortable/", "authors": [ diff --git a/index.html b/index.html index 3e83346..c706443 100644 --- a/index.html +++ b/index.html @@ -173,7 +173,7 @@