Browse Source

#205: * support 'clone' for angular

issue-210
RubaXa 10 years ago
parent
commit
a5532380f9
  1. 1
      Sortable.js
  2. 9
      ng-sortable.js

1
Sortable.js

@ -57,6 +57,7 @@
evt.item = targetEl || rootEl; evt.item = targetEl || rootEl;
evt.from = fromEl || rootEl; evt.from = fromEl || rootEl;
evt.clone = cloneEl;
evt.oldIndex = startIndex; evt.oldIndex = startIndex;
evt.newIndex = newIndex; evt.newIndex = newIndex;

9
ng-sortable.js

@ -74,6 +74,13 @@
items.splice(newIndex, 0, removed); items.splice(newIndex, 0, removed);
if (evt.clone) {
newIndex = Sortable.utils.index(evt.clone);
prevItems.splice(newIndex, 0, removed);
evt.from.removeChild(evt.clone);
}
evt.from.appendChild(evt.item); // revert element evt.from.appendChild(evt.item); // revert element
} else { } else {
items.splice(newIndex, 0, items.splice(oldIndex, 1)[0]); items.splice(newIndex, 0, items.splice(oldIndex, 1)[0]);
@ -114,7 +121,7 @@
sortable = null; sortable = null;
}); });
if (!/{|}/.test(ngSortable)) { // todo: ugly if (ngSortable && !/{|}/.test(ngSortable)) { // todo: ugly
angular.forEach(['sort', 'disabled', 'draggable', 'handle', 'animation'], function (name) { angular.forEach(['sort', 'disabled', 'draggable', 'handle', 'animation'], function (name) {
scope.$watch(ngSortable + '.' + name, function (value) { scope.$watch(ngSortable + '.' + name, function (value) {
if (value !== void 0) { if (value !== void 0) {

Loading…
Cancel
Save