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

Commit 1a5b8c1

Browse files
author
AngularUI (via TravisCI)
committed
Travis commit : build 482
1 parent 1499f88 commit 1a5b8c1

File tree

3 files changed

+20
-19
lines changed

3 files changed

+20
-19
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-ui-sortable",
3-
"version": "0.15.0",
3+
"version": "0.15.1",
44
"main": ["./sortable.js"],
55
"dependencies": {
66
"angular": ">=1.2.x",

sortable.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* angular-ui-sortable - This directive allows you to jQueryUI Sortable.
3-
* @version v0.15.0 - 2016-10-15
3+
* @version v0.15.1 - 2016-11-28
44
* @link http://angular-ui.github.com
55
* @license MIT
66
*/
@@ -378,29 +378,30 @@ angular.module('ui.sortable', [])
378378
// If the received flag hasn't be set on the item, this is a
379379
// normal sort, if dropindex is set, the item was moved, so move
380380
// the items in the list.
381-
if(!ui.item.sortable.received &&
382-
('dropindex' in ui.item.sortable) &&
383-
!ui.item.sortable.isCanceled()) {
381+
var wasMoved = ('dropindex' in ui.item.sortable) &&
382+
!ui.item.sortable.isCanceled();
383+
384+
if (wasMoved && !ui.item.sortable.received) {
384385

385386
scope.$apply(function () {
386387
ngModel.$modelValue.splice(
387388
ui.item.sortable.dropindex, 0,
388389
ngModel.$modelValue.splice(ui.item.sortable.index, 1)[0]);
389390
});
390-
} else {
391-
// if the item was not moved, then restore the elements
391+
} else if (!wasMoved &&
392+
!angular.equals(element.contents().toArray(), savedNodes.toArray())) {
393+
// if the item was not moved
394+
// and the DOM element order has changed,
395+
// then restore the elements
392396
// so that the ngRepeat's comment are correct.
393-
if ((!('dropindex' in ui.item.sortable) || ui.item.sortable.isCanceled()) &&
394-
!angular.equals(element.contents(), savedNodes)) {
395-
396-
var sortingHelper = getSortingHelper(element, ui, savedNodes);
397-
if (sortingHelper && sortingHelper.length) {
398-
// Restore all the savedNodes except from the sorting helper element.
399-
// That way it will be garbage collected.
400-
savedNodes = savedNodes.not(sortingHelper);
401-
}
402-
savedNodes.appendTo(element);
397+
398+
var sortingHelper = getSortingHelper(element, ui, savedNodes);
399+
if (sortingHelper && sortingHelper.length) {
400+
// Restore all the savedNodes except from the sorting helper element.
401+
// That way it will be garbage collected.
402+
savedNodes = savedNodes.not(sortingHelper);
403403
}
404+
savedNodes.appendTo(element);
404405
}
405406

406407
// It's now safe to clear the savedNodes

sortable.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)