Skip to content

Commit 7c5e5d9

Browse files
author
Paul Bakaus
committed
draggable: revert option now accepts "invalid", "valid" and true as possible options: true always reverts, "invalid" only reverts when not dropped on a possible target, and "valid" does the contrary (implements #2914)
1 parent 069fcab commit 7c5e5d9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ui/ui.draggable.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,11 @@ $.widget("ui.draggable", $.extend($.ui.mouse, {
216216
mouseStop: function(e) {
217217

218218
//If we are using droppables, inform the manager about the drop
219+
var dropped = false;
219220
if ($.ui.ddmanager && !this.options.dropBehaviour)
220-
$.ui.ddmanager.drop(this, e);
221-
222-
if(this.options.revert) {
221+
var dropped = $.ui.ddmanager.drop(this, e);
222+
223+
if((this.options.revert == "invalid" && !dropped) || (this.options.revert == "valid" && dropped) || this.options.revert === true) {
223224
var self = this;
224225
$(this.helper).animate(this.originalPosition, parseInt(this.options.revert, 10) || 500, function() {
225226
self.propagate("stop", e);

0 commit comments

Comments
 (0)