Browse Source

Added onChoose event.

This event will fire when an element is chosen, and is particularly
useful for providing the user with a visual, auditory or tactile indication,
in case a delay was enabled.
pull/615/head
TaliLavi 9 years ago committed by Tali Lavi
parent
commit
0d17cf0943
  1. 13
      README.md
  2. 4
      Sortable.html
  3. 5
      Sortable.js
  4. 4
      Sortable.min.js
  5. 2
      component.json

13
README.md

@ -78,12 +78,17 @@ var sortable = new Sortable(el, {
dataTransfer.setData('Text', dragEl.textContent);
},
// dragging started
// Element is chosen
onChoose: function (/**Event*/evt) {
evt.oldIndex; // element index within parent
},
// Element dragging started
onStart: function (/**Event*/evt) {
evt.oldIndex; // element index within parent
},
// dragging ended
// Element dragging ended
onEnd: function (/**Event*/evt) {
evt.oldIndex; // element's old index within parent
evt.newIndex; // element's new index within parent
@ -635,11 +640,11 @@ Link to the active instance.
```html
<!-- CDNJS :: Sortable (https://cdnjs.com/) -->
<script src="//cdnjs.cloudflare.com/ajax/libs/Sortable/1.3.0-rc1/Sortable.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/Sortable/1.4.0-rc1/Sortable.min.js"></script>
<!-- jsDelivr :: Sortable (http://www.jsdelivr.com/) -->
<script src="//cdn.jsdelivr.net/sortable/1.3.0-rc1/Sortable.min.js"></script>
<script src="//cdn.jsdelivr.net/sortable/1.4.0-rc1/Sortable.min.js"></script>
<!-- jsDelivr :: Sortable :: Latest (http://www.jsdelivr.com/) -->

4
Sortable.html

@ -88,6 +88,10 @@
this.fire("remove", e)
},
onChoose: e => {
this.fire("choose", e)
},
onStart: e => {
this.fire("start", e)
},

5
Sortable.js

@ -336,6 +336,9 @@
// Bind the events: dragstart/dragend
_this._triggerDragStart(touch);
// Drag start event
_dispatchEvent(this, rootEl, 'choose', dragEl, rootEl, oldIndex);
};
// Disable "draggable"
@ -1244,6 +1247,6 @@
// Export
Sortable.version = '1.3.0';
Sortable.version = '1.4.0';
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",
"main": "Sortable.js",
"version": "1.3.0",
"version": "1.4.0",
"homepage": "http://rubaxa.github.io/Sortable/",
"repo": "RubaXa/Sortable",
"authors": [

Loading…
Cancel
Save