Changeset 491 for trunk/ui/ui.draggable.js
- Timestamp:
- 07/28/08 17:10:51 (20 months ago)
- Files:
-
- 1 modified
-
trunk/ui/ui.draggable.js (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ui/ui.draggable.js
r489 r491 68 68 top: e.pageY - this.offset.top 69 69 }; 70 71 this.scrollTopParent = function(el) { 72 do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode); 73 return $(document); 74 }(this.element); 75 this.scrollLeftParent = function(el) { 76 do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-x'))) return el; el = el.parent(); } while (el[0].parentNode); 77 return $(document); 78 }(this.element); 70 79 71 80 this.offsetParent = this.helper.offsetParent(); var po = this.offsetParent.offset(); //Get the offsetParent and cache its position … … 78 87 var p = this.element.position(); //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helpers 79 88 this.offset.relative = this.cssPosition == "relative" ? { 80 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this. offsetParent[0].scrollTop,81 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this. offsetParent[0].scrollLeft89 top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollTopParent[0].scrollTop, 90 left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollLeftParent[0].scrollLeft 82 91 } : { top: 0, left: 0 }; 83 92 … … 138 147 + this.offset.relative.top * mod // Only for relative positioned nodes: Relative offset from element to offset parent 139 148 + this.offset.parent.top * mod // The offsetParent's offset without borders (offset + border) 140 - (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this. offsetParent[0].scrollTop) * mod // The offsetParent's scroll position, not if the element is fixed149 - (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.scrollTopParent[0].scrollTop) * mod // The offsetParent's scroll position, not if the element is fixed 141 150 + (this.cssPosition == "fixed" ? $(document).scrollTop() : 0) * mod 142 151 + this.margins.top * mod //Add the margin (you don't want the margin counting in intersection methods) … … 146 155 + this.offset.relative.left * mod // Only for relative positioned nodes: Relative offset from element to offset parent 147 156 + this.offset.parent.left * mod // The offsetParent's offset without borders (offset + border) 148 - (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this. offsetParent[0].scrollLeft) * mod // The offsetParent's scroll position, not if the element is fixed157 - (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.scrollLeftParent[0].scrollLeft) * mod // The offsetParent's scroll position, not if the element is fixed 149 158 + (this.cssPosition == "fixed" ? $(document).scrollLeft() : 0) * mod 150 159 + this.margins.left * mod //Add the margin (you don't want the margin counting in intersection methods) … … 161 170 - this.offset.relative.top // Only for relative positioned nodes: Relative offset from element to offset parent 162 171 - this.offset.parent.top // The offsetParent's offset without borders (offset + border) 163 + (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this. offsetParent[0].scrollTop) // The offsetParent's scroll position, not if the element is fixed172 + (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.scrollTopParent[0].scrollTop) // The offsetParent's scroll position, not if the element is fixed 164 173 - (this.cssPosition == "fixed" ? $(document).scrollTop() : 0) 165 174 ), … … 169 178 - this.offset.relative.left // Only for relative positioned nodes: Relative offset from element to offset parent 170 179 - this.offset.parent.left // The offsetParent's offset without borders (offset + border) 171 + (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this. offsetParent[0].scrollLeft) // The offsetParent's scroll position, not if the element is fixed180 + (this.cssPosition == "fixed" || (this.cssPosition == "absolute" && this.offsetParent[0] == document.body) ? 0 : this.scrollLeftParent[0].scrollLeft) // The offsetParent's scroll position, not if the element is fixed 172 181 - (this.cssPosition == "fixed" ? $(document).scrollLeft() : 0) 173 182 ) … … 332 341 o.scrollSpeed = o.scrollSpeed || 20; 333 342 334 i.overflowY = function(el) { 335 do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-y'))) return el; el = el.parent(); } while (el[0].parentNode); 336 return $(document); 337 }(this); 338 i.overflowX = function(el) { 339 do { if(/auto|scroll/.test(el.css('overflow')) || (/auto|scroll/).test(el.css('overflow-x'))) return el; el = el.parent(); } while (el[0].parentNode); 340 return $(document); 341 }(this); 342 343 if(i.overflowY[0] != document && i.overflowY[0].tagName != 'HTML') i.overflowYOffset = i.overflowY.offset(); 344 if(i.overflowX[0] != document && i.overflowX[0].tagName != 'HTML') i.overflowXOffset = i.overflowX.offset(); 343 if(i.scrollTopParent[0] != document && i.scrollTopParent[0].tagName != 'HTML') i.overflowYOffset = i.scrollTopParent.offset(); 344 if(i.scrollLeftParent[0] != document && i.scrollLeftParent[0].tagName != 'HTML') i.overflowXOffset = i.scrollLeftParent.offset(); 345 345 346 346 }, … … 349 349 var o = ui.options; 350 350 var i = $(this).data("draggable"); 351 352 if(i. overflowY[0] != document && i.overflowY[0].tagName != 'HTML') {353 if((i.overflowYOffset.top + i. overflowY[0].offsetHeight) - e.pageY < o.scrollSensitivity)354 i. overflowY[0].scrollTop = i.overflowY[0].scrollTop + o.scrollSpeed;351 352 if(i.scrollTopParent[0] != document && i.scrollTopParent[0].tagName != 'HTML') { 353 if((i.overflowYOffset.top + i.scrollTopParent[0].offsetHeight) - e.pageY < o.scrollSensitivity) 354 i.scrollTopParent[0].scrollTop = i.scrollTopParent[0].scrollTop + o.scrollSpeed; 355 355 if(e.pageY - i.overflowYOffset.top < o.scrollSensitivity) 356 i. overflowY[0].scrollTop = i.overflowY[0].scrollTop - o.scrollSpeed;356 i.scrollTopParent[0].scrollTop = i.scrollTopParent[0].scrollTop - o.scrollSpeed; 357 357 358 358 } else { … … 363 363 } 364 364 365 if(i. overflowX[0] != document && i.overflowX[0].tagName != 'HTML') {366 if((i.overflowXOffset.left + i. overflowX[0].offsetWidth) - e.pageX < o.scrollSensitivity)367 i. overflowX[0].scrollLeft = i.overflowX[0].scrollLeft + o.scrollSpeed;365 if(i.scrollLeftParent[0] != document && i.scrollLeftParent[0].tagName != 'HTML') { 366 if((i.overflowXOffset.left + i.scrollLeftParent[0].offsetWidth) - e.pageX < o.scrollSensitivity) 367 i.scrollLeftParent[0].scrollLeft = i.scrollLeftParent[0].scrollLeft + o.scrollSpeed; 368 368 if(e.pageX - i.overflowXOffset.left < o.scrollSensitivity) 369 i. overflowX[0].scrollLeft = i.overflowX[0].scrollLeft - o.scrollSpeed;369 i.scrollLeftParent[0].scrollLeft = i.scrollLeftParent[0].scrollLeft - o.scrollSpeed; 370 370 } else { 371 371 if(e.pageX - $(document).scrollLeft() < o.scrollSensitivity)