mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Droppable: only consider pointer location with tolerance "pointer"
Fixes #4977 Closes gh-991
This commit is contained in:
parent
d434fdbcc2
commit
87081b855c
@ -96,7 +96,7 @@ test( "tolerance, intersect", function() {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
test( "tolerance, pointer", function() {
|
test( "tolerance, pointer", function() {
|
||||||
expect( 2 );
|
expect( 3 );
|
||||||
|
|
||||||
var draggable, droppable,
|
var draggable, droppable,
|
||||||
dataset = [
|
dataset = [
|
||||||
@ -132,6 +132,19 @@ test( "tolerance, pointer", function() {
|
|||||||
dy: ( data[ 1 ] - $( draggable ).position().top )
|
dy: ( data[ 1 ] - $( draggable ).position().top )
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// http://bugs.jqueryui.com/ticket/4977 - tolerance, pointer - bug when pointer outside draggable
|
||||||
|
draggable.css({ top: 0, left: 0 }).draggable( "option", "axis", "x" );
|
||||||
|
droppable.css({ top: 15, left: 15 });
|
||||||
|
|
||||||
|
droppable.unbind( "drop" ).bind( "drop", function() {
|
||||||
|
ok( true, "drop fires as long as pointer is within droppable" );
|
||||||
|
});
|
||||||
|
|
||||||
|
$( draggable ).simulate( "drag", {
|
||||||
|
dx: 10,
|
||||||
|
dy: 10
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -191,7 +191,7 @@ $.widget( "ui.droppable", {
|
|||||||
!inst.options.disabled &&
|
!inst.options.disabled &&
|
||||||
inst.options.scope === draggable.options.scope &&
|
inst.options.scope === draggable.options.scope &&
|
||||||
inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
|
inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
|
||||||
$.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance )
|
$.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
|
||||||
) { childrenIntersection = true; return false; }
|
) { childrenIntersection = true; return false; }
|
||||||
});
|
});
|
||||||
if ( childrenIntersection ) {
|
if ( childrenIntersection ) {
|
||||||
@ -229,14 +229,13 @@ $.ui.intersect = (function() {
|
|||||||
return ( x >= reference ) && ( x < ( reference + size ) );
|
return ( x >= reference ) && ( x < ( reference + size ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return function( draggable, droppable, toleranceMode ) {
|
return function( draggable, droppable, toleranceMode, event ) {
|
||||||
|
|
||||||
if ( !droppable.offset ) {
|
if ( !droppable.offset ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var draggableLeft, draggableTop,
|
var x1 = ( draggable.positionAbs || draggable.position.absolute ).left,
|
||||||
x1 = ( draggable.positionAbs || draggable.position.absolute ).left,
|
|
||||||
y1 = ( draggable.positionAbs || draggable.position.absolute ).top,
|
y1 = ( draggable.positionAbs || draggable.position.absolute ).top,
|
||||||
x2 = x1 + draggable.helperProportions.width,
|
x2 = x1 + draggable.helperProportions.width,
|
||||||
y2 = y1 + draggable.helperProportions.height,
|
y2 = y1 + draggable.helperProportions.height,
|
||||||
@ -254,9 +253,7 @@ $.ui.intersect = (function() {
|
|||||||
t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
|
t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
|
||||||
y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
|
y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
|
||||||
case "pointer":
|
case "pointer":
|
||||||
draggableLeft = ( ( draggable.positionAbs || draggable.position.absolute ).left + ( draggable.clickOffset || draggable.offset.click ).left );
|
return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
|
||||||
draggableTop = ( ( draggable.positionAbs || draggable.position.absolute ).top + ( draggable.clickOffset || draggable.offset.click ).top );
|
|
||||||
return isOverAxis( draggableTop, t, droppable.proportions().height ) && isOverAxis( draggableLeft, l, droppable.proportions().width );
|
|
||||||
case "touch":
|
case "touch":
|
||||||
return (
|
return (
|
||||||
( y1 >= t && y1 <= b ) || // Top edge touching
|
( y1 >= t && y1 <= b ) || // Top edge touching
|
||||||
@ -326,7 +323,7 @@ $.ui.ddmanager = {
|
|||||||
if ( !this.options ) {
|
if ( !this.options ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance ) ) {
|
if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
|
||||||
dropped = this._drop.call( this, event ) || dropped;
|
dropped = this._drop.call( this, event ) || dropped;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -363,7 +360,7 @@ $.ui.ddmanager = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var parentInstance, scope, parent,
|
var parentInstance, scope, parent,
|
||||||
intersects = $.ui.intersect( draggable, this, this.options.tolerance ),
|
intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
|
||||||
c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
|
c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
|
||||||
if ( !c ) {
|
if ( !c ) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user