Skip to content

Commit a002680

Browse files
author
Paul Bakaus
committed
sortable:fixed #3019, stop being fird too early
1 parent dd584fb commit a002680

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

tests/sortable.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,17 @@ test("defaults", function() {
122122

123123
});
124124

125+
test("#3019: Stop fires too early", function() {
126+
127+
var helper = null;
128+
el = $("#sortable").sortable({ stop: function(e, ui) {
129+
helper = ui.helper;
130+
}});
131+
132+
sort($("li", el)[0], 0, 40, 2, 'Dragging the sortable');
133+
equals(helper, null, "helper should be false");
134+
135+
});
136+
125137

126138
})(jQuery);

ui/ui.sortable.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -519,11 +519,9 @@ $.widget("ui.sortable", $.extend($.ui.mouse, {
519519
left: cur.left - this.offset.parent.left - self.margins.left + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollLeft),
520520
top: cur.top - this.offset.parent.top - self.margins.top + (this.offsetParent[0] == document.body ? 0 : this.offsetParent[0].scrollTop)
521521
}, parseInt(this.options.revert, 10) || 500, function() {
522-
self.propagate("stop", e, null, noPropagation);
523522
self.clear(e);
524523
});
525524
} else {
526-
this.propagate("stop", e, null, noPropagation);
527525
this.clear(e, noPropagation);
528526
}
529527

@@ -554,10 +552,15 @@ $.widget("ui.sortable", $.extend($.ui.mouse, {
554552
}
555553

556554
this.dragging = false;
557-
if(this.cancelHelperRemoval) return false;
555+
if(this.cancelHelperRemoval) {
556+
this.propagate("stop", e, null, noPropagation);
557+
return false;
558+
}
559+
558560
$(this.currentItem).css('visibility', '');
559561
if(this.placeholder) this.placeholder.remove();
560-
this.helper.remove();
562+
this.helper.remove(); this.helper = null;
563+
this.propagate("stop", e, null, noPropagation);
561564

562565
return true;
563566

0 commit comments

Comments
 (0)