mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Draggable: Uncommented failing scrolling tests and fixed them
This commit is contained in:
parent
1495a61298
commit
d84cf1d716
@ -38,9 +38,7 @@ TestHelpers.draggable = {
|
|||||||
},
|
},
|
||||||
setScroll: function( what ) {
|
setScroll: function( what ) {
|
||||||
if(what) {
|
if(what) {
|
||||||
// todo: currently, the draggable interaction doesn't properly account for scrolled pages,
|
$(document).scrollTop(100); $(document).scrollLeft(100);
|
||||||
// uncomment the line below to make the tests fail that should when the page is scrolled
|
|
||||||
// $(document).scrollTop(100); $(document).scrollLeft(100);
|
|
||||||
} else {
|
} else {
|
||||||
$("#main").scrollTop(100); $("#main").scrollLeft(100);
|
$("#main").scrollTop(100); $("#main").scrollLeft(100);
|
||||||
}
|
}
|
||||||
|
50
ui/jquery.ui.draggable.js
vendored
50
ui/jquery.ui.draggable.js
vendored
@ -305,7 +305,9 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_handleScrolling: function( pointerPosition ) {
|
_handleScrolling: function( pointerPosition ) {
|
||||||
var scrollTop = this.scrollParent.scrollTop(),
|
|
||||||
|
var newScrollTop, newScrollLeft,
|
||||||
|
scrollTop = this.scrollParent.scrollTop(),
|
||||||
scrollLeft = this.scrollParent.scrollLeft(),
|
scrollLeft = this.scrollParent.scrollLeft(),
|
||||||
scrollSensitivity = this.scrollSensitivity,
|
scrollSensitivity = this.scrollSensitivity,
|
||||||
// overflowOffset is only set when scrollParent is not doc/html
|
// overflowOffset is only set when scrollParent is not doc/html
|
||||||
@ -318,24 +320,49 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
|||||||
xRight = this.overflow.width + overflowLeft - pointerPosition.x,
|
xRight = this.overflow.width + overflowLeft - pointerPosition.x,
|
||||||
xLeft = pointerPosition.x- overflowLeft,
|
xLeft = pointerPosition.x- overflowLeft,
|
||||||
yBottom = this.overflow.height + overflowTop - pointerPosition.y,
|
yBottom = this.overflow.height + overflowTop - pointerPosition.y,
|
||||||
yTop = pointerPosition.y - overflowTop;
|
yTop = pointerPosition.y - overflowTop,
|
||||||
|
// accounts for change in scrollbar to modify "original" pointer so calc
|
||||||
|
change;
|
||||||
|
|
||||||
// Handle vertical scrolling
|
// Handle vertical scrolling
|
||||||
if ( yBottom < scrollSensitivity ) {
|
if ( yBottom < scrollSensitivity ) {
|
||||||
this.scrollParent.scrollTop( scrollTop +
|
|
||||||
this._speed( scrollSensitivity - yBottom ) );
|
change = this._speed( scrollSensitivity - yBottom );
|
||||||
|
this.scrollParent.scrollTop( scrollTop + change );
|
||||||
|
this.originalPointer.y = this.originalPointer.y + change;
|
||||||
|
|
||||||
} else if ( yTop < scrollSensitivity ) {
|
} else if ( yTop < scrollSensitivity ) {
|
||||||
this.scrollParent.scrollTop( scrollTop -
|
|
||||||
this._speed( scrollSensitivity - yTop ) );
|
change = this._speed( scrollSensitivity - yTop );
|
||||||
|
newScrollTop = scrollTop - change;
|
||||||
|
|
||||||
|
// Don't do anything unless new value is "real"
|
||||||
|
if ( newScrollTop >= 0 ) {
|
||||||
|
this.scrollParent.scrollTop( newScrollTop );
|
||||||
|
this._speed( scrollSensitivity - yTop )
|
||||||
|
this.originalPointer.y = this.originalPointer.y - change;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle horizontal scrolling
|
// Handle horizontal scrolling
|
||||||
if ( xRight < scrollSensitivity ) {
|
if ( xRight < scrollSensitivity ) {
|
||||||
this.scrollParent.scrollLeft( scrollLeft +
|
|
||||||
this._speed( scrollSensitivity - xRight ) );
|
change = this._speed( scrollSensitivity - xRight );
|
||||||
|
this.scrollParent.scrollLeft( scrollLeft + change);
|
||||||
|
this.originalPointer.x = this.originalPointer.x + change;
|
||||||
|
|
||||||
} else if ( xLeft < scrollSensitivity ) {
|
} else if ( xLeft < scrollSensitivity ) {
|
||||||
this.scrollParent.scrollLeft( scrollLeft -
|
|
||||||
this._speed( scrollSensitivity - xLeft ) );
|
change = this._speed( scrollSensitivity - xLeft );
|
||||||
|
newScrollLeft = scrollLeft - change;
|
||||||
|
|
||||||
|
// Don't do anything unless new value is "real"
|
||||||
|
if ( newScrollLeft >= 0 ) {
|
||||||
|
this.scrollParent.scrollLeft( newScrollLeft );
|
||||||
|
this.originalPointer.x = this.originalPointer.x - change;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -370,6 +397,7 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
|||||||
|
|
||||||
// Places draggable where event, or user via event/callback, indicates
|
// Places draggable where event, or user via event/callback, indicates
|
||||||
_setCss: function() {
|
_setCss: function() {
|
||||||
|
|
||||||
var newLeft = this.position.left,
|
var newLeft = this.position.left,
|
||||||
newTop = this.position.top;
|
newTop = this.position.top;
|
||||||
|
|
||||||
@ -382,7 +410,7 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: does this work with nested scrollable parents?
|
// TODO: does this work with nested scrollable parents?
|
||||||
if ( this.cssPosition !== "fixed" ) {
|
if ( this.cssPosition !== "fixed") {
|
||||||
newLeft += this.scrollParent.scrollLeft();
|
newLeft += this.scrollParent.scrollLeft();
|
||||||
newTop += this.scrollParent.scrollTop();
|
newTop += this.scrollParent.scrollTop();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user