mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-10-05 01:44:18 +00:00
sortable: important restructuring in the sort function - callback and droppables/intersection now receive proper position information (also fixes #3022)
This commit is contained in:
parent
75b29b66df
commit
1b8cc84978
@ -494,11 +494,20 @@ $.widget("ui.sortable", $.extend($.ui.mouse, {
|
|||||||
},
|
},
|
||||||
mouseDrag: function(e) {
|
mouseDrag: function(e) {
|
||||||
|
|
||||||
|
|
||||||
//Compute the helpers position
|
//Compute the helpers position
|
||||||
this.position = this.generatePosition(e);
|
this.position = this.generatePosition(e);
|
||||||
this.positionAbs = this.convertPositionTo("absolute");
|
this.positionAbs = this.convertPositionTo("absolute");
|
||||||
|
|
||||||
|
//Call the internal plugins
|
||||||
|
$.ui.plugin.call(this, "sort", [e, this.ui()]);
|
||||||
|
|
||||||
|
//Regenerate the absolute position used for position checks
|
||||||
|
this.positionAbs = this.convertPositionTo("absolute");
|
||||||
|
|
||||||
|
//Set the helper's position
|
||||||
|
this.helper[0].style.left = this.position.left+'px';
|
||||||
|
this.helper[0].style.top = this.position.top+'px';
|
||||||
|
|
||||||
//Rearrange
|
//Rearrange
|
||||||
for (var i = this.items.length - 1; i >= 0; i--) {
|
for (var i = this.items.length - 1; i >= 0; i--) {
|
||||||
var intersection = this.intersectsWithEdge(this.items[i]);
|
var intersection = this.intersectsWithEdge(this.items[i]);
|
||||||
@ -520,15 +529,12 @@ $.widget("ui.sortable", $.extend($.ui.mouse, {
|
|||||||
//Post events to containers
|
//Post events to containers
|
||||||
this.contactContainers(e);
|
this.contactContainers(e);
|
||||||
|
|
||||||
//Call plugins and callbacks
|
|
||||||
this.propagate("sort", e);
|
|
||||||
|
|
||||||
if(!this.options.axis || this.options.axis == "x") this.helper[0].style.left = this.position.left+'px';
|
|
||||||
if(!this.options.axis || this.options.axis == "y") this.helper[0].style.top = this.position.top+'px';
|
|
||||||
|
|
||||||
//Interconnect with droppables
|
//Interconnect with droppables
|
||||||
if($.ui.ddmanager) $.ui.ddmanager.drag(this, e);
|
if($.ui.ddmanager) $.ui.ddmanager.drag(this, e);
|
||||||
|
|
||||||
|
//Call callbacks
|
||||||
|
this.element.triggerHandler("sort", [e, this.ui()], this.options["sort"]);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -719,4 +725,15 @@ $.ui.plugin.add("sortable", "scroll", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$.ui.plugin.add("sortable", "axis", {
|
||||||
|
sort: function(e, ui) {
|
||||||
|
|
||||||
|
var i = $(this).data("sortable");
|
||||||
|
|
||||||
|
if(ui.options.axis == "y") i.position.left = i.originalPosition.left;
|
||||||
|
if(ui.options.axis == "x") i.position.top = i.originalPosition.top;
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
Loading…
Reference in New Issue
Block a user