sortable: fixed regression that caused wrong offset calculation if the helper option has been set to "original"

This commit is contained in:
Paul Bakaus 2008-12-02 12:47:53 +00:00
parent 152531d370
commit 6c93b4e2f0

View File

@ -100,8 +100,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
//Cache the margins of the original element //Cache the margins of the original element
this._cacheMargins(); this._cacheMargins();
//Store the helper's css position //Get the next scrolling parent
this.cssPosition = this.helper.css("position");
this.scrollParent = this.helper.scrollParent(); this.scrollParent = this.helper.scrollParent();
//The element's absolute position on the page minus margins //The element's absolute position on the page minus margins
@ -111,6 +110,11 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
left: this.offset.left - this.margins.left left: this.offset.left - this.margins.left
}; };
// Only after we got the offset, we can change the helper's position to absolute
// TODO: Still need to figure out a way to make relative sorting possible
this.helper.css("position", "absolute");
this.cssPosition = this.helper.css("position");
$.extend(this.offset, { $.extend(this.offset, {
click: { //Where the click happened, relative to the element click: { //Where the click happened, relative to the element
left: event.pageX - this.offset.left, left: event.pageX - this.offset.left,
@ -636,9 +640,6 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width()); if(helper[0].style.width == '' || o.forceHelperSize) helper.width(this.currentItem.width());
if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height()); if(helper[0].style.height == '' || o.forceHelperSize) helper.height(this.currentItem.height());
//TODO: Still need to figure out a way to make relative sorting possible
helper.css("position", "absolute");
return helper; return helper;
}, },