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

Commit 028b2a2

Browse files
committed
fix(sortable): clear ui.item.sortable properties after drag stop
1 parent d21f532 commit 028b2a2

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
@@ -28,6 +28,10 @@ angular.module('ui.sortable', [])
2828
return helperOption === 'clone' || (typeof helperOption === 'function' && ui.item.sortable.isCustomHelperUsed());
2929
}
3030

31+
function afterStop(e, ui) {
32+
ui.item.sortable._destroy();
33+
}
34+
3135
var opts = {};
3236

3337
var callbacks = {
@@ -78,7 +82,14 @@ angular.module('ui.sortable', [])
7882
return !!ui.item.sortable._isCustomHelperUsed;
7983
},
8084
_isCanceled: false,
81-
_isCustomHelperUsed: ui.item.sortable._isCustomHelperUsed
85+
_isCustomHelperUsed: ui.item.sortable._isCustomHelperUsed,
86+
_destroy: function () {
87+
for (var key in ui.item.sortable) {
88+
if (ui.item.sortable.hasOwnProperty(key)) {
89+
ui.item.sortable[key] = undefined;
90+
}
91+
}
92+
}
8293
};
8394
};
8495

@@ -233,6 +244,8 @@ angular.module('ui.sortable', [])
233244
// call apply after stop
234245
value = combineCallbacks(
235246
value, function() { scope.$apply(); });
247+
248+
value = combineCallbacks(value, afterStop);
236249
}
237250
// wrap the callback
238251
value = combineCallbacks(callbacks[key], value);
@@ -247,6 +260,9 @@ angular.module('ui.sortable', [])
247260

248261
angular.forEach(callbacks, function(value, key) {
249262
opts[key] = combineCallbacks(value, opts[key]);
263+
if( key === 'stop' ){
264+
opts[key] = combineCallbacks(opts[key], afterStop);
265+
}
250266
});
251267

252268
} else {

0 commit comments

Comments
 (0)