Droppable: Added pointer intersect

This commit is contained in:
Dave Stein 2011-11-27 16:59:11 -05:00
parent a28fb9f98f
commit 722e4bcf18

View File

@ -63,7 +63,7 @@ $.widget( "ui.droppable", {
draggableRight: ui.offset.left + this.draggableProportions.width, draggableRight: ui.offset.left + this.draggableProportions.width,
draggableBottom: ui.offset.top + this.draggableProportions.height draggableBottom: ui.offset.top + this.draggableProportions.height
}, },
over = this[ handleFunc ]( edges, ui ); over = this[ handleFunc ]( event, edges, ui );
// If there is sufficient overlap as deemed by tolerance // If there is sufficient overlap as deemed by tolerance
if ( over ) { if ( over ) {
@ -89,7 +89,7 @@ $.widget( "ui.droppable", {
// Determines if draggable is over droppable based on intersect tolerance // Determines if draggable is over droppable based on intersect tolerance
// TODO: move all tolerance methods into a hash // TODO: move all tolerance methods into a hash
// $.ui.droppable.tolerance.intersect // $.ui.droppable.tolerance.intersect
_handleIntersect: function( edges, ui ) { _handleIntersect: function( event, edges, ui ) {
var xDiff = edges.draggableRight - this.offset.left, var xDiff = edges.draggableRight - this.offset.left,
yDiff = edges.draggableBottom - this.offset.top, yDiff = edges.draggableBottom - this.offset.top,
// TODO: is there really any need to round here? // TODO: is there really any need to round here?
@ -112,7 +112,7 @@ $.widget( "ui.droppable", {
}, },
// Determines if draggable is over droppable based on touch tolerance // Determines if draggable is over droppable based on touch tolerance
_handleTouch: function( edges, ui ) { _handleTouch: function( event, edges, ui ) {
var xOverlap = edges.draggableRight >= this.offset.left && var xOverlap = edges.draggableRight >= this.offset.left &&
ui.offset.left <= edges.right, ui.offset.left <= edges.right,
yOverlap = edges.draggableBottom >= this.offset.top && yOverlap = edges.draggableBottom >= this.offset.top &&
@ -120,6 +120,18 @@ $.widget( "ui.droppable", {
return xOverlap && yOverlap; return xOverlap && yOverlap;
}, },
// Determines if draggable is over droppable based on touch tolerance
_handlePointer: function( event, edges, ui ) {
var xOverlap = event.pageX >= this.offset.left &&
event.pageX <= edges.right,
yOverlap = event.pageY >= this.offset.top &&
event.pageY <= edges.bottom;
return xOverlap && yOverlap;
},
// TODO: shouldn't this be dragStop? // TODO: shouldn't this be dragStop?
_mouseUp: function( event ) { _mouseUp: function( event ) {