aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Bakaus <paul.bakaus@googlemail.com>2009-01-08 11:19:48 +0000
committerPaul Bakaus <paul.bakaus@googlemail.com>2009-01-08 11:19:48 +0000
commit122786c4b2216321f53d10ab094f96f9d1ecec11 (patch)
tree6ffa015183aea375cd12b587308c88880f4d8517
parent1c647d9cba9a6ad00200663b545e793e78fc4377 (diff)
downloadjquery-ui-122786c4b2216321f53d10ab094f96f9d1ecec11.tar.gz
jquery-ui-122786c4b2216321f53d10ab094f96f9d1ecec11.zip
draggable: second partial fix for remaining scroll issues (for the special case, subtract scrollLeft/scrollTop already in getParentOffset, so calculations become easier in _generatePosition)
-rw-r--r--ui/ui.draggable.js23
1 files changed, 13 insertions, 10 deletions
diff --git a/ui/ui.draggable.js b/ui/ui.draggable.js
index a97b75ce4..82d09c77a 100644
--- a/ui/ui.draggable.js
+++ b/ui/ui.draggable.js
@@ -196,7 +196,18 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
_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 @@ $.widget("ui.draggable", $.extend({}, $.ui.mouse, {
_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