提交 e648a737 编写于 作者: L Lebedev Konstantin

Merge pull request #615 from TaliLavi/dev

Added onPickup event.
...@@ -78,12 +78,17 @@ var sortable = new Sortable(el, { ...@@ -78,12 +78,17 @@ var sortable = new Sortable(el, {
dataTransfer.setData('Text', dragEl.textContent); 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) { onStart: function (/**Event*/evt) {
evt.oldIndex; // element index within parent evt.oldIndex; // element index within parent
}, },
// dragging ended // Element dragging ended
onEnd: function (/**Event*/evt) { onEnd: function (/**Event*/evt) {
evt.oldIndex; // element's old index within parent evt.oldIndex; // element's old index within parent
evt.newIndex; // element's new index within parent evt.newIndex; // element's new index within parent
...@@ -635,11 +640,11 @@ Link to the active instance. ...@@ -635,11 +640,11 @@ Link to the active instance.
```html ```html
<!-- CDNJS :: Sortable (https://cdnjs.com/) --> <!-- 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/) --> <!-- 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/) --> <!-- jsDelivr :: Sortable :: Latest (http://www.jsdelivr.com/) -->
......
...@@ -88,6 +88,10 @@ ...@@ -88,6 +88,10 @@
this.fire("remove", e) this.fire("remove", e)
}, },
onChoose: e => {
this.fire("choose", e)
},
onStart: e => { onStart: e => {
this.fire("start", e) this.fire("start", e)
}, },
......
...@@ -336,6 +336,9 @@ ...@@ -336,6 +336,9 @@
// Bind the events: dragstart/dragend // Bind the events: dragstart/dragend
_this._triggerDragStart(touch); _this._triggerDragStart(touch);
// Drag start event
_dispatchEvent(this, rootEl, 'choose', dragEl, rootEl, oldIndex);
}; };
// Disable "draggable" // Disable "draggable"
...@@ -1244,6 +1247,6 @@ ...@@ -1244,6 +1247,6 @@
// Export // Export
Sortable.version = '1.3.0'; Sortable.version = '1.4.0';
return Sortable; return Sortable;
}); });
此差异已折叠。
{ {
"name": "Sortable", "name": "Sortable",
"main": "Sortable.js", "main": "Sortable.js",
"version": "1.3.0", "version": "1.4.0",
"homepage": "http://rubaxa.github.io/Sortable/", "homepage": "http://rubaxa.github.io/Sortable/",
"repo": "RubaXa/Sortable", "repo": "RubaXa/Sortable",
"authors": [ "authors": [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册