Skip to content

Commit

Permalink
issue SortableJS#29: Fixed item reappearance when it is pulled from o…
Browse files Browse the repository at this point in the history
…ne list to another
  • Loading branch information
serjum committed Jul 10, 2017
1 parent f129b5c commit ff009b5
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions angular-legacy-sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
var rhs = match[2];

return function postLink(scope, $el) {
scope.ngSortable.isAngular = true;
var itemsExpr = $parse(rhs);
var getSource = function getSource() {
return itemsExpr(scope.$parent) || [];
Expand All @@ -78,7 +79,7 @@
watchers = [],
offDestroy,
sortable
;
;

el[expando] = getSource;

Expand Down Expand Up @@ -117,24 +118,24 @@
removed = angular.copy(removed);
prevItems.splice(Sortable.utils.index(evt.clone, sortable.options.draggable), 0, prevItems.splice(oldIndex, 1)[0]);

if (evt.from.contains(evt.clone)) {
evt.from.removeChild(evt.clone);
}
// if (evt.from.contains(evt.clone)) {
// evt.from.removeChild(evt.clone);
// }
}
else {
prevItems.splice(oldIndex, 1);
}

items.splice(newIndex, 0, removed);

evt.from.insertBefore(evt.item, nextSibling); // revert element
// evt.from.insertBefore(evt.item, nextSibling); // revert element
}
else {
items.splice(newIndex, 0, items.splice(oldIndex, 1)[0]);

// move ng-repeat comment node to right position
if (nextSibling.nodeType === Node.COMMENT_NODE) {
evt.from.insertBefore(nextSibling, evt.item.nextSibling);
// evt.from.insertBefore(nextSibling, evt.item.nextSibling);
}
}

Expand Down Expand Up @@ -173,6 +174,7 @@
scope.$apply();
},
onAdd: function (/**Event*/evt) {

evt.clone = false;
_sync(evt);
_emitEvent(evt, removed);
Expand Down

0 comments on commit ff009b5

Please sign in to comment.