Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 689b200

Browse files
committed
feat: end up with the initial complete event $emit implementation
1 parent 70653ab commit 689b200

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/sortable.js

+5-12
Original file line numberDiff line numberDiff line change
@@ -345,11 +345,7 @@ angular.module('ui.sortable', [])
345345
// Save current drop position but only if this is not a second
346346
// update that happens when moving between lists because then
347347
// the value will be overwritten with the old value
348-
349-
var wasMoved = ('dropindex' in ui.item.sortable) &&
350-
!ui.item.sortable.isCanceled();
351-
352-
if(!ui.item.sortable.received) {
348+
if (!ui.item.sortable.received) {
353349
ui.item.sortable.dropindex = getItemIndex(ui.item);
354350
var droptarget = ui.item.closest('[ui-sortable], [data-ui-sortable], [x-ui-sortable]');
355351
ui.item.sortable.droptarget = droptarget;
@@ -383,25 +379,21 @@ angular.module('ui.sortable', [])
383379
// it's safe to clear the restored nodes since:
384380
// update is currently running and
385381
// stop is not called for the target list.
386-
if(ui.item.sortable.received) {
382+
if (ui.item.sortable.received) {
387383
savedNodes = null;
388384
}
389385

390386
// If received is true (an item was dropped in from another list)
391387
// then we add the new item to this list otherwise wait until the
392388
// stop event where we will know if it was a sort or item was
393389
// moved here from another list
394-
if(ui.item.sortable.received && !ui.item.sortable.isCanceled()) {
390+
if (ui.item.sortable.received && !ui.item.sortable.isCanceled()) {
395391
scope.$apply(function () {
396392
ngModel.$modelValue.splice(ui.item.sortable.dropindex, 0,
397393
ui.item.sortable.moved);
398394
});
395+
scope.$emit('ui-sortable:moved', ui);
399396
}
400-
401-
if(wasMoved && !ui.item.sortable.received){
402-
scope.$emit('sortable:wasMoved');
403-
}
404-
405397
};
406398

407399
callbacks.stop = function(e, ui) {
@@ -418,6 +410,7 @@ angular.module('ui.sortable', [])
418410
ui.item.sortable.dropindex, 0,
419411
ngModel.$modelValue.splice(ui.item.sortable.index, 1)[0]);
420412
});
413+
scope.$emit('ui-sortable:moved', ui);
421414
} else if (!wasMoved &&
422415
!angular.equals(element.contents().toArray(), savedNodes.toArray())) {
423416
// if the item was not moved

0 commit comments

Comments
 (0)