From 8032bcaab7de3cbc3778cf632af050e82d7d27b6 Mon Sep 17 00:00:00 2001 From: skaczorowski Date: Tue, 1 Jul 2014 13:29:05 +0200 Subject: [PATCH] added start and stop events --- Sortable.js | 6 ++++++ index.html | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Sortable.js b/Sortable.js index 3bc41c1..c337420 100644 --- a/Sortable.js +++ b/Sortable.js @@ -84,6 +84,8 @@ options.onAdd = _bind(this, options.onAdd || noop); options.onUpdate = _bind(this, options.onUpdate || noop); options.onRemove = _bind(this, options.onRemove || noop); + options.onStartDragging = _bind(this, options.onStartDragging || noop); + options.onStopDragging = _bind(this, options.onStopDragging || noop); // Export group name @@ -114,6 +116,8 @@ _on(el, 'add', options.onAdd); _on(el, 'update', options.onUpdate); _on(el, 'remove', options.onRemove); + _on(el, 'start', options.onStartDragging); + _on(el, 'stop', options.onStopDragging); _on(el, 'mousedown', this._onTapStart); _on(el, 'touchstart', this._onTapStart); @@ -306,6 +310,7 @@ _on(document, 'drop', this._onDrop); } + dragEl.dispatchEvent(_createEvent('start', dragEl)); setTimeout(this._applyEffects); }, @@ -401,6 +406,7 @@ // Update event dragEl.dispatchEvent(_createEvent('update', dragEl)); } + dragEl.dispatchEvent(_createEvent('stop', dragEl)); } // Set NULL diff --git a/index.html b/index.html index 96714a1..a46c716 100644 --- a/index.html +++ b/index.html @@ -313,14 +313,18 @@ sort.destroy(); group: "words", onAdd: function (evt){ console.log('onAdd.foo:', evt.item); }, onUpdate: function (evt){ console.log('onUpdate.foo:', evt.item); }, - onRemove: function (evt){ console.log('onRemove.foo:', evt.item); } + onRemove: function (evt){ console.log('onRemove.foo:', evt.item); }, + onStartDragging:function(evt){ console.log('onStartDragging.foo:',evt.item);}, + onStopDragging: function(evt){ console.log('onStopDragging.foo:',evt.item);} }); new Sortable(bar, { group: "words", onAdd: function (evt){ console.log('onAdd.bar:', evt.item); }, onUpdate: function (evt){ console.log('onUpdate.bar:', evt.item); }, - onRemove: function (evt){ console.log('onRemove.bar:', evt.item); } + onRemove: function (evt){ console.log('onRemove.bar:', evt.item); }, + onStartDragging:function(evt){ console.log('onStartDragging.foo:',evt.item);}, + onStopDragging: function(evt){ console.log('onStopDragging.foo:',evt.item);} });