Browse Source

#671: + 'clone' event

pull/699/head
RubaXa 9 years ago
parent
commit
2ec12f7ecd
  1. 6
      README.md
  2. 4
      Sortable.html
  3. 2
      Sortable.js
  4. 4
      knockout-sortable.js
  5. 2
      ng-sortable.js
  6. 7
      react-sortable-mixin.js

6
README.md

@ -131,6 +131,12 @@ var sortable = new Sortable(el, {
evt.related; // HTMLElement on which have guided
evt.relatedRect; // TextRectangle
// return false; — for cancel
},
// Called when creating a clone of element
onClone: function (/**Event*/evt) {
var origEl = evt.item;
var cloneEl = evt.clone;
}
});
```

4
Sortable.html

@ -110,6 +110,10 @@
onMove: function(e) {
this.fire("move", e)
},
onClone: function(e) {
this.fire("clone", e)
}
}))
},

2
Sortable.js

@ -547,10 +547,10 @@
cloneEl = dragEl.cloneNode(true);
_css(cloneEl, 'display', 'none');
rootEl.insertBefore(cloneEl, dragEl);
_dispatchEvent(this, rootEl, 'clone', dragEl);
}
if (useFallback) {
if (useFallback === 'touch') {
// Bind touch events
_on(document, 'touchmove', this._onTouchMove);

4
knockout-sortable.js

@ -1,4 +1,4 @@
(function (factory) {
(function (factory) {
"use strict";
if (typeof define === "function" && define.amd) {
// AMD anonymous module
@ -21,7 +21,7 @@
// It's seems that we cannot update the eventhandlers after we've created
// the sortable, so define them in init instead of update
['onStart', 'onEnd', 'onRemove', 'onAdd', 'onUpdate', 'onSort', 'onFilter'].forEach(function (e) {
['onStart', 'onEnd', 'onRemove', 'onAdd', 'onUpdate', 'onSort', 'onFilter', 'onMove', 'onClone'].forEach(function (e) {
if (options[e] || eventHandlers[e])
options[e] = function (eventType, parentVM, parentBindings, handler, e) {
var itemVM = ko.dataFor(e.item),

2
ng-sortable.js

@ -173,7 +173,7 @@
angular.forEach([
'sort', 'disabled', 'draggable', 'handle', 'animation', 'group', 'ghostClass', 'filter',
'onStart', 'onEnd', 'onAdd', 'onUpdate', 'onRemove', 'onSort'
'onStart', 'onEnd', 'onAdd', 'onUpdate', 'onRemove', 'onSort', 'onMove', 'onClone'
], function (name) {
watchers.push(scope.$watch('ngSortable.' + name, function (value) {
if (value !== void 0) {

7
react-sortable-mixin.js vendored

@ -35,7 +35,8 @@
onRemove: 'handleRemove',
onSort: 'handleSort',
onFilter: 'handleFilter',
onMove: 'handleMove'
onMove: 'handleMove',
onClone: 'handleClone'
};
@ -120,13 +121,13 @@
}
newState[_getModelName(this)] = items;
if (copyOptions.stateHandler) {
this[copyOptions.stateHandler](newState);
} else {
this.setState(newState);
}
(this !== _activeComponent) && _activeComponent.setState(remoteState);
}

Loading…
Cancel
Save