diff options
author | Paul Bakaus <paul.bakaus@googlemail.com> | 2008-07-17 15:04:42 +0000 |
---|---|---|
committer | Paul Bakaus <paul.bakaus@googlemail.com> | 2008-07-17 15:04:42 +0000 |
commit | db258edf2a4411e888e13180ec60b4d56436808c (patch) | |
tree | b9bf091490c8fdefe284adacde27791196a90cad /ui/ui.draggable.js | |
parent | 872c757f40e7a7efb88f1dab865a6ef93e490727 (diff) | |
download | jquery-ui-db258edf2a4411e888e13180ec60b4d56436808c.tar.gz jquery-ui-db258edf2a4411e888e13180ec60b4d56436808c.zip |
draggable: fixed relative position bug (please NEVER check in elem.style just for performance optimizations)
Diffstat (limited to 'ui/ui.draggable.js')
-rw-r--r-- | ui/ui.draggable.js | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/ui/ui.draggable.js b/ui/ui.draggable.js index 10bc32e52..a4225093e 100644 --- a/ui/ui.draggable.js +++ b/ui/ui.draggable.js @@ -15,38 +15,30 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, { init: function() { - //Initialize needed constants - var o = this.options, positioned = /^(?:r|a|f)/, element = this.element[0]; - - if (!this.element.length) - return false; - - var style = element.style || {}, - position = style.position || "static"; - - //Position the node - if (o.helper == 'original' && !positioned.test(position)) - style.position = 'relative'; + if (this.options.helper == 'original' && !(/^(?:r|a|f)/).test(this.element.css("position"))) + this.element[0].style.position = 'relative'; - (o.disabled && this.element.addClass('ui-draggable-disabled')); + (this.options.disabled && this.element.addClass('ui-draggable-disabled')); this.mouseInit(); }, mouseStart: function(e) { + var o = this.options; - if (this.helper || o.disabled || $(e.target).is('.ui-resizable-handle')) return false; + if (this.helper || o.disabled || $(e.target).is('.ui-resizable-handle')) + return false; + //Check if we have a valid handle var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false; - - $(this.options.handle, this.element).find("*").andSelf().each(function() { if(this == e.target) handle = true; }); if (!handle) return false; - if($.ui.ddmanager) $.ui.ddmanager.current = this; + if($.ui.ddmanager) + $.ui.ddmanager.current = this; //Create and append the visible helper this.helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [e])) : (o.helper == 'clone' ? this.element.clone() : this.element); |