mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Droppable: Answered TODO comment about Math.round
This commit is contained in:
parent
2799b4a67f
commit
da1b946e66
50
ui/jquery.ui.draggable.js
vendored
50
ui/jquery.ui.draggable.js
vendored
@ -18,10 +18,7 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
||||
widgetEventPrefix: "drag",
|
||||
|
||||
options: {
|
||||
helper: null,
|
||||
// TODO: remove scroll options
|
||||
scrollSensitivity: 20,
|
||||
scrollSpeed: 20
|
||||
helper: null
|
||||
},
|
||||
|
||||
// dragEl: element being dragged (original or helper)
|
||||
@ -74,42 +71,51 @@ $.widget( "ui.draggable", $.ui.interaction, {
|
||||
},
|
||||
|
||||
_handleScrolling: function( event ) {
|
||||
var scrollTop = this.scrollParent.scrollTop(),
|
||||
scrollLeft = this.scrollParent.scrollLeft();
|
||||
var distances = {},
|
||||
scrollTop = this.scrollParent.scrollTop(),
|
||||
scrollLeft = this.scrollParent.scrollLeft(),
|
||||
scrollSensitivity = 20,
|
||||
xScrollSpeed = 20,
|
||||
yScrollSpeed = 20;
|
||||
|
||||
// overflowOffset is only set when scrollParent is not doc/html
|
||||
if ( !this.overflowOffset ) {
|
||||
|
||||
// Handle vertical scrolling
|
||||
if ( ( ( this.overflow.height + scrollTop ) - event.pageY ) < this.options.scrollSensitivity ) {
|
||||
this.scrollParent.scrollTop( scrollTop + this.options.scrollSpeed );
|
||||
if ( ( ( this.overflow.height + scrollTop ) - event.pageY ) < scrollSensitivity ) {
|
||||
this.scrollParent.scrollTop( scrollTop + yScrollSpeed );
|
||||
}
|
||||
else if ( event.pageY < ( scrollTop + this.options.scrollSensitivity ) ) {
|
||||
this.scrollParent.scrollTop( scrollTop - this.options.scrollSpeed );
|
||||
else if ( event.pageY < ( scrollTop + scrollSensitivity ) ) {
|
||||
this.scrollParent.scrollTop( scrollTop - yScrollSpeed );
|
||||
}
|
||||
|
||||
distances.xRight = ( this.overflow.width + scrollLeft ) - event.pageX;
|
||||
distances.xLeft = event.pageX - scrollLeft;
|
||||
|
||||
|
||||
|
||||
// Handle horizontal scrolling
|
||||
if ( ( ( this.overflow.width + scrollLeft ) - event.pageX ) < this.options.scrollSensitivity ) {
|
||||
this.scrollParent.scrollLeft( scrollLeft + this.options.scrollSpeed );
|
||||
if ( distances.xRight < scrollSensitivity ) {
|
||||
this.scrollParent.scrollLeft( scrollLeft + xScrollSpeed );
|
||||
}
|
||||
else if ( event.pageX < ( scrollLeft + this.options.scrollSensitivity ) ) {
|
||||
this.scrollParent.scrollLeft( scrollLeft - this.options.scrollSpeed );
|
||||
else if ( distances.xLeft < scrollSensitivity ) {
|
||||
this.scrollParent.scrollLeft( scrollLeft - xScrollSpeed );
|
||||
}
|
||||
} else {
|
||||
// Handle vertical scrolling
|
||||
if ( ( event.pageY + this.options.scrollSensitivity ) > ( this.overflow.height + this.overflowOffset.top ) ) {
|
||||
this.scrollParent.scrollTop( scrollTop + this.options.scrollSpeed );
|
||||
if ( ( event.pageY + scrollSensitivity ) > ( this.overflow.height + this.overflowOffset.top ) ) {
|
||||
this.scrollParent.scrollTop( scrollTop + yScrollSpeed );
|
||||
}
|
||||
else if ( ( event.pageY - this.options.scrollSensitivity ) < this.overflowOffset.top ) {
|
||||
this.scrollParent.scrollTop( scrollTop - this.options.scrollSpeed );
|
||||
else if ( ( event.pageY - scrollSensitivity ) < this.overflowOffset.top ) {
|
||||
this.scrollParent.scrollTop( scrollTop - yScrollSpeed );
|
||||
}
|
||||
|
||||
// Handle horizontal scrolling
|
||||
if ( ( event.pageX + this.options.scrollSensitivity ) > ( this.overflow.width + this.overflowOffset.left ) ) {
|
||||
this.scrollParent.scrollLeft( scrollLeft + this.options.scrollSpeed );
|
||||
if ( ( event.pageX + scrollSensitivity ) > ( this.overflow.width + this.overflowOffset.left ) ) {
|
||||
this.scrollParent.scrollLeft( scrollLeft + xScrollSpeed );
|
||||
}
|
||||
else if ( ( event.pageX - this.options.scrollSensitivity ) < this.overflowOffset.left ) {
|
||||
this.scrollParent.scrollLeft( scrollLeft - this.options.scrollSpeed );
|
||||
else if ( ( event.pageX - scrollSensitivity ) < this.overflowOffset.left ) {
|
||||
this.scrollParent.scrollLeft( scrollLeft - xScrollSpeed );
|
||||
}
|
||||
}
|
||||
},
|
||||
|
3
ui/jquery.ui.droppable.js
vendored
3
ui/jquery.ui.droppable.js
vendored
@ -92,7 +92,8 @@ $.widget( "ui.droppable", {
|
||||
_handleIntersect: function( event, edges, ui ) {
|
||||
var xDiff = edges.draggableRight - this.offset.left,
|
||||
yDiff = edges.draggableBottom - this.offset.top,
|
||||
// TODO: is there really any need to round here?
|
||||
|
||||
// Round to normalize between browsers since some handle non-integer values
|
||||
xHalfway = Math.round( this.proportions.width / 2 ),
|
||||
yHalfway = Math.round( this.proportions.height / 2 ),
|
||||
xOverlap = false,
|
||||
|
Loading…
Reference in New Issue
Block a user