Browse Source

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

experimental
RubaXa 9 years ago
parent
commit
9968038260
  1. 12
      Sortable.html
  2. 9
      Sortable.js

12
Sortable.html

@ -61,9 +61,9 @@
var options = {}
Object.keys(this.properties).forEach(function(key) {
options[key] = this[key]
})
});
this.sortable = Sortable.create(this, Object.assign(options, {
var eventCallbacks = {
onUpdate: function (e) {
if (template) {
template.splice("items", e.newIndex, 0, template.splice("items", e.oldIndex, 1)[0])
@ -115,7 +115,13 @@
onClone: function(e) {
this.fire("clone", e)
}
}))
};
Object.keys(eventCallbacks).forEach(function(name){
options[name] = eventCallbacks[name];
});
this.sortable = Sortable.create(this, options);
},
detached: function() {

9
Sortable.js

@ -254,7 +254,7 @@
// Bind all private methods
for (var fn in this) {
if (fn.charAt(0) === '_') {
if (fn.charAt(0) === '_' && typeof this[fn] === 'function') {
this[fn] = this[fn].bind(this);
}
}
@ -823,15 +823,16 @@
newIndex = _index(dragEl, options.draggable);
if (newIndex >= 0) {
// drag from one list and drop into another
_dispatchEvent(null, parentEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
_dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
// Add event
_dispatchEvent(null, parentEl, 'add', dragEl, rootEl, oldIndex, newIndex);
// Remove event
_dispatchEvent(this, rootEl, 'remove', dragEl, rootEl, oldIndex, newIndex);
// drag from one list and drop into another
_dispatchEvent(null, parentEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
_dispatchEvent(this, rootEl, 'sort', dragEl, rootEl, oldIndex, newIndex);
}
}
else {

Loading…
Cancel
Save