diff options
author | Scott González <scott.gonzalez@gmail.com> | 2009-08-03 13:13:13 +0000 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2009-08-03 13:13:13 +0000 |
commit | ec4d469a36a656c57c336a5063ed6d53334a8479 (patch) | |
tree | 30dd73fcfc414b7ea340a1f0c8eb190c30c28e0e /ui | |
parent | a962d52902bdccbd9d91ecc419750c0d5d3abcac (diff) | |
download | jquery-ui-ec4d469a36a656c57c336a5063ed6d53334a8479.tar.gz jquery-ui-ec4d469a36a656c57c336a5063ed6d53334a8479.zip |
Draggable: Support hash, array, string for cursorAt option. Partial fix for #2525 - Standardised way to pass coordinates to plugins.
Diffstat (limited to 'ui')
-rw-r--r-- | ui/ui.draggable.js | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/ui/ui.draggable.js b/ui/ui.draggable.js index f877bd14a..fabf8e439 100644 --- a/ui/ui.draggable.js +++ b/ui/ui.draggable.js @@ -103,8 +103,7 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { this.originalPageY = event.pageY; //Adjust the mouse offset relative to the helper if 'cursorAt' is supplied - if(o.cursorAt) - this._adjustOffsetFromHelper(o.cursorAt); + (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt)); //Set a containment if given in the options if(o.containment) @@ -202,10 +201,24 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { }, _adjustOffsetFromHelper: function(obj) { - if(obj.left != undefined) this.offset.click.left = obj.left + this.margins.left; - if(obj.right != undefined) this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left; - 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 (typeof obj == 'string') { + obj = obj.split(' '); + } + 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() { |