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

Commit 1d18029

Browse files
committed
fix(sortable): clear ui.item.sortable properties after drag stop
1 parent 2e22b0e commit 1d18029

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/sortable.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ angular.module('ui.sortable', [])
3333
return (/left|right/).test(item.css('float')) || (/inline|table-cell/).test(item.css('display'));
3434
}
3535

36+
function afterStop(e, ui) {
37+
ui.item.sortable._destroy();
38+
}
39+
3640
var opts = {};
3741

3842
// directive specific options
@@ -95,7 +99,14 @@ angular.module('ui.sortable', [])
9599
return !!ui.item.sortable._isCustomHelperUsed;
96100
},
97101
_isCanceled: false,
98-
_isCustomHelperUsed: ui.item.sortable._isCustomHelperUsed
102+
_isCustomHelperUsed: ui.item.sortable._isCustomHelperUsed,
103+
_destroy: function () {
104+
for (var key in ui.item.sortable) {
105+
if (ui.item.sortable.hasOwnProperty(key)) {
106+
ui.item.sortable[key] = undefined;
107+
}
108+
}
109+
}
99110
};
100111
};
101112

@@ -262,6 +273,8 @@ angular.module('ui.sortable', [])
262273
// call apply after stop
263274
value = combineCallbacks(
264275
value, function() { scope.$apply(); });
276+
277+
value = combineCallbacks(value, afterStop);
265278
}
266279
// wrap the callback
267280
value = combineCallbacks(callbacks[key], value);
@@ -277,6 +290,9 @@ angular.module('ui.sortable', [])
277290

278291
angular.forEach(callbacks, function(value, key) {
279292
opts[key] = combineCallbacks(value, opts[key]);
293+
if( key === 'stop' ){
294+
opts[key] = combineCallbacks(opts[key], afterStop);
295+
}
280296
});
281297

282298
} else {

0 commit comments

Comments
 (0)