mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-10-05 01:44:18 +00:00
Sortable: Support hash, array, string for cursorAt option. Partial fix for #2525 - Standardised way to pass coordinates to plugins.
This commit is contained in:
parent
ec4d469a36
commit
61e06a0e13
@ -132,8 +132,7 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
|
|||||||
this.originalPageY = event.pageY;
|
this.originalPageY = event.pageY;
|
||||||
|
|
||||||
//Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
|
//Adjust the mouse offset relative to the helper if 'cursorAt' is supplied
|
||||||
if(o.cursorAt)
|
(o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
|
||||||
this._adjustOffsetFromHelper(o.cursorAt);
|
|
||||||
|
|
||||||
//Cache the former DOM position
|
//Cache the former DOM position
|
||||||
this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
|
this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
|
||||||
@ -724,10 +723,24 @@ $.widget("ui.sortable", $.extend({}, $.ui.mouse, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_adjustOffsetFromHelper: function(obj) {
|
_adjustOffsetFromHelper: function(obj) {
|
||||||
if(obj.left != undefined) this.offset.click.left = obj.left + this.margins.left;
|
if (typeof obj == 'string') {
|
||||||
if(obj.right != undefined) this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
|
obj = obj.split(' ');
|
||||||
if(obj.top != undefined) this.offset.click.top = obj.top + this.margins.top;
|
}
|
||||||
if(obj.bottom != undefined) this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
|
if ($.isArray(obj)) {
|
||||||
|
obj = {left: +obj[0], top: +obj[1] || 0};
|
||||||
|
}
|
||||||
|
if ('left' in obj) {
|
||||||
|
this.offset.click.left = obj.left + this.margins.left;
|
||||||
|
}
|
||||||
|
if ('right' in obj) {
|
||||||
|
this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
|
||||||
|
}
|
||||||
|
if ('top' in obj) {
|
||||||
|
this.offset.click.top = obj.top + this.margins.top;
|
||||||
|
}
|
||||||
|
if ('bottom' in obj) {
|
||||||
|
this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_getParentOffset: function() {
|
_getParentOffset: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user