@@ -284,12 +284,12 @@ $.widget("ui.draggable", $.ui.mouse, {
284284 // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
285285 // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
286286 // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
287- if ( this . cssPosition == 'absolute' && this . scrollParent [ 0 ] != document && $ . ui . contains ( this . scrollParent [ 0 ] , this . offsetParent [ 0 ] ) ) {
287+ if ( this . cssPosition == 'absolute' && this . scrollParent [ 0 ] != this . element [ 0 ] . ownerDocument && $ . ui . contains ( this . scrollParent [ 0 ] , this . offsetParent [ 0 ] ) ) {
288288 po . left += this . scrollParent . scrollLeft ( ) ;
289289 po . top += this . scrollParent . scrollTop ( ) ;
290290 }
291291
292- if ( ( this . offsetParent [ 0 ] == document . body ) //This needs to be actually done for all browsers, since pageX/pageY includes this information
292+ if ( ( this . offsetParent [ 0 ] == this . element [ 0 ] . ownerDocument . body ) //This needs to be actually done for all browsers, since pageX/pageY includes this information
293293 || ( this . offsetParent [ 0 ] . tagName && this . offsetParent [ 0 ] . tagName . toLowerCase ( ) == 'html' && $ . browser . msie ) ) //Ugly IE fix
294294 po = { top : 0 , left : 0 } ;
295295
@@ -360,7 +360,7 @@ $.widget("ui.draggable", $.ui.mouse, {
360360
361361 if ( ! pos ) pos = this . position ;
362362 var mod = d == "absolute" ? 1 : - 1 ;
363- 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 = ( / ( h t m l | b o d y ) / i) . test ( scroll [ 0 ] . tagName ) ;
363+ var o = this . options , scroll = this . cssPosition == 'absolute' && ! ( this . scrollParent [ 0 ] != this . element [ 0 ] . ownerDocument && $ . ui . contains ( this . scrollParent [ 0 ] , this . offsetParent [ 0 ] ) ) ? this . offsetParent : this . scrollParent , scrollIsRootNode = ( / ( h t m l | b o d y ) / i) . test ( scroll [ 0 ] . tagName ) ;
364364
365365 return {
366366 top : (
@@ -381,7 +381,7 @@ $.widget("ui.draggable", $.ui.mouse, {
381381
382382 _generatePosition : function ( event ) {
383383
384- 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 = ( / ( h t m l | b o d y ) / i) . test ( scroll [ 0 ] . tagName ) ;
384+ var o = this . options , scroll = this . cssPosition == 'absolute' && ! ( this . scrollParent [ 0 ] != this . element [ 0 ] . ownerDocument && $ . ui . contains ( this . scrollParent [ 0 ] , this . offsetParent [ 0 ] ) ) ? this . offsetParent : this . scrollParent , scrollIsRootNode = ( / ( h t m l | b o d y ) / i) . test ( scroll [ 0 ] . tagName ) ;
385385 var pageX = event . pageX ;
386386 var pageY = event . pageY ;
387387
@@ -647,13 +647,13 @@ $.ui.plugin.add("draggable", "opacity", {
647647$ . ui . plugin . add ( "draggable" , "scroll" , {
648648 start : function ( event , ui ) {
649649 var i = $ ( this ) . data ( "draggable" ) ;
650- if ( i . scrollParent [ 0 ] != document && i . scrollParent [ 0 ] . tagName != 'HTML' ) i . overflowOffset = i . scrollParent . offset ( ) ;
650+ if ( i . scrollParent [ 0 ] != i . element [ 0 ] . ownerDocument && i . scrollParent [ 0 ] . tagName != 'HTML' ) i . overflowOffset = i . scrollParent . offset ( ) ;
651651 } ,
652652 drag : function ( event , ui ) {
653653
654- var i = $ ( this ) . data ( "draggable" ) , o = i . options , scrolled = false ;
654+ var i = $ ( this ) . data ( "draggable" ) , o = i . options , scrolled = false , doc = i . element [ 0 ] . ownerDocument ;
655655
656- if ( i . scrollParent [ 0 ] != document && i . scrollParent [ 0 ] . tagName != 'HTML' ) {
656+ if ( i . scrollParent [ 0 ] != doc && i . scrollParent [ 0 ] . tagName != 'HTML' ) {
657657
658658 if ( ! o . axis || o . axis != 'x' ) {
659659 if ( ( i . overflowOffset . top + i . scrollParent [ 0 ] . offsetHeight ) - event . pageY < o . scrollSensitivity )
@@ -672,17 +672,17 @@ $.ui.plugin.add("draggable", "scroll", {
672672 } else {
673673
674674 if ( ! o . axis || o . axis != 'x' ) {
675- if ( event . pageY - $ ( document ) . scrollTop ( ) < o . scrollSensitivity )
676- scrolled = $ ( document ) . scrollTop ( $ ( document ) . scrollTop ( ) - o . scrollSpeed ) ;
677- else if ( $ ( window ) . height ( ) - ( event . pageY - $ ( document ) . scrollTop ( ) ) < o . scrollSensitivity )
678- scrolled = $ ( document ) . scrollTop ( $ ( document ) . scrollTop ( ) + o . scrollSpeed ) ;
675+ if ( event . pageY - $ ( doc ) . scrollTop ( ) < o . scrollSensitivity )
676+ scrolled = $ ( doc ) . scrollTop ( $ ( doc ) . scrollTop ( ) - o . scrollSpeed ) ;
677+ else if ( $ ( window ) . height ( ) - ( event . pageY - $ ( doc ) . scrollTop ( ) ) < o . scrollSensitivity )
678+ scrolled = $ ( doc ) . scrollTop ( $ ( doc ) . scrollTop ( ) + o . scrollSpeed ) ;
679679 }
680680
681681 if ( ! o . axis || o . axis != 'y' ) {
682- if ( event . pageX - $ ( document ) . scrollLeft ( ) < o . scrollSensitivity )
683- scrolled = $ ( document ) . scrollLeft ( $ ( document ) . scrollLeft ( ) - o . scrollSpeed ) ;
684- else if ( $ ( window ) . width ( ) - ( event . pageX - $ ( document ) . scrollLeft ( ) ) < o . scrollSensitivity )
685- scrolled = $ ( document ) . scrollLeft ( $ ( document ) . scrollLeft ( ) + o . scrollSpeed ) ;
682+ if ( event . pageX - $ ( doc ) . scrollLeft ( ) < o . scrollSensitivity )
683+ scrolled = $ ( doc ) . scrollLeft ( $ ( doc ) . scrollLeft ( ) - o . scrollSpeed ) ;
684+ else if ( $ ( window ) . width ( ) - ( event . pageX - $ ( doc ) . scrollLeft ( ) ) < o . scrollSensitivity )
685+ scrolled = $ ( doc ) . scrollLeft ( $ ( doc ) . scrollLeft ( ) + o . scrollSpeed ) ;
686686 }
687687
688688 }
0 commit comments