r1553 - trunk/ui

r1553 - trunk/ui


Author: paul.bakaus
Date: Thu Jan 8 03:19:48 2009
New Revision: 1553
Modified:
trunk/ui/ui.draggable.js
Log:
draggable: second partial fix for remaining scroll issues (for the special
case, subtract scrollLeft/scrollTop already in getParentOffset, so
calculations become easier in _generatePosition)
Modified: trunk/ui/ui.draggable.js
==============================================================================
--- trunk/ui/ui.draggable.js    (original)
+++ trunk/ui/ui.draggable.js    Thu Jan 8 03:19:48 2009
@@ -196,7 +196,18 @@
    _getParentOffset: function() {
-        this.offsetParent = this.helper.offsetParent(); var po =
this.offsetParent.offset();            //Get the offsetParent and cache its position
+        //Get the offsetParent and cache its position
+        this.offsetParent = this.helper.offsetParent();
+        var po = this.offsetParent.offset();
+        
+        // This is a special case where we need to modify a offset calculated on
start, since the following happened:
+        // 1. The position of the helper is absolute, so it's position is
calculated based on the next positioned parent
+        // 2. The actual offset parent is a child of the scroll parent, and the
scroll parent isn't the document, which means that
+        // the scroll is included in the initial calculation of the offset of
the parent, and never recalculated upon drag
+        if(this.cssPosition == 'absolute' && this.scrollParent[0] != document &&
$.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
+            po.left += this.scrollParent.scrollLeft();
+            po.top += this.scrollParent.scrollTop();
+        }
        if((this.offsetParent[0] == document.body && $.browser.mozilla)    //Ugly
FF3 fix
        || (this.offsetParent[0].tagName &&
this.offsetParent[0].tagName.toLowerCase() == 'html' && $.browser.msie))
//Ugly IE fix
@@ -289,15 +300,7 @@
    _generatePosition: function(event) {
-        var o = this.options, scroll = this[(this.cssPosition
== 'absolute' ? 'offset' : 'scroll')+'Parent'], scrollIsRootNode = (/(html|
body)/i).test(scroll[0].tagName);
-
-        // This is a special case where we need to modify a offset calculated on
start, since the following happened:
-        // 1. The position of the helper is absolute, so it's position is
calculated based on the next positioned parent
-        // 2. The actual offset parent is a child of the scroll parent, and the
scroll parent isn't the document, which means that
-        // the scroll is included in the initial calculation of the offset of
the parent, and never recalculated upon drag
-        if(this.cssPosition == 'absolute' && this.scrollParent[0] != document &&
$.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
-            this.offset.parent = this._getParentOffset();
-        }
+        var o = this.options, scroll = this.cssPosition == 'absolute'
&& !(this.scrollParent[0] != document &&
$.ui.contains(this.scrollParent[0], this.offsetParent[0])) ?
this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|
body)/i).test(scroll[0].tagName);
        // This is another very weird special case that only happens for
relative elements:
        // 1. If the css position is relative