@@ -284,12 +284,12 @@ $.widget("ui.draggable", $.ui.mouse, {
284
284
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
285
285
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
286
286
// 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 ] ) ) {
288
288
po . left += this . scrollParent . scrollLeft ( ) ;
289
289
po . top += this . scrollParent . scrollTop ( ) ;
290
290
}
291
291
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
293
293
|| ( this . offsetParent [ 0 ] . tagName && this . offsetParent [ 0 ] . tagName . toLowerCase ( ) == 'html' && $ . browser . msie ) ) //Ugly IE fix
294
294
po = { top : 0 , left : 0 } ;
295
295
@@ -360,7 +360,7 @@ $.widget("ui.draggable", $.ui.mouse, {
360
360
361
361
if ( ! pos ) pos = this . position ;
362
362
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 ) ;
364
364
365
365
return {
366
366
top : (
@@ -381,7 +381,7 @@ $.widget("ui.draggable", $.ui.mouse, {
381
381
382
382
_generatePosition : function ( event ) {
383
383
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 ) ;
385
385
var pageX = event . pageX ;
386
386
var pageY = event . pageY ;
387
387
@@ -647,13 +647,13 @@ $.ui.plugin.add("draggable", "opacity", {
647
647
$ . ui . plugin . add ( "draggable" , "scroll" , {
648
648
start : function ( event , ui ) {
649
649
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 ( ) ;
651
651
} ,
652
652
drag : function ( event , ui ) {
653
653
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 ;
655
655
656
- if ( i . scrollParent [ 0 ] != document && i . scrollParent [ 0 ] . tagName != 'HTML' ) {
656
+ if ( i . scrollParent [ 0 ] != doc && i . scrollParent [ 0 ] . tagName != 'HTML' ) {
657
657
658
658
if ( ! o . axis || o . axis != 'x' ) {
659
659
if ( ( i . overflowOffset . top + i . scrollParent [ 0 ] . offsetHeight ) - event . pageY < o . scrollSensitivity )
@@ -672,17 +672,17 @@ $.ui.plugin.add("draggable", "scroll", {
672
672
} else {
673
673
674
674
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 ) ;
679
679
}
680
680
681
681
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 ) ;
686
686
}
687
687
688
688
}
0 commit comments