mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Droppable: Only react to drag events if they're not canceled. Fixed pointer intersection.
This commit is contained in:
parent
003bbf42fc
commit
2c9ee0252d
23
ui/jquery.ui.droppable.js
vendored
23
ui/jquery.ui.droppable.js
vendored
@ -18,17 +18,19 @@ var guid = 0,
|
|||||||
droppables = {};
|
droppables = {};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
// TODO: we need to react after the event, in case an event handler changes the position
|
|
||||||
// TODO: don't react if the event is canceled
|
|
||||||
// TODO: we need access to pointerPosition
|
|
||||||
var orig = $.ui.draggable.prototype._trigger;
|
var orig = $.ui.draggable.prototype._trigger;
|
||||||
$.ui.draggable.prototype._trigger = function( type, event, ui ) {
|
$.ui.draggable.prototype._trigger = function( type, event, ui ) {
|
||||||
var droppable,
|
var droppable,
|
||||||
method = "_draggable" + type.substr( 0, 1 ).toUpperCase() + type.substr( 1 );
|
method = "_draggable" + type.substr( 0, 1 ).toUpperCase() + type.substr( 1 ),
|
||||||
|
allowed = orig.apply( this, arguments );
|
||||||
|
|
||||||
|
if ( allowed ) {
|
||||||
for ( droppable in droppables ) {
|
for ( droppable in droppables ) {
|
||||||
droppables[ droppable ][ method ].call( droppables[ droppable ], event, ui );
|
droppables[ droppable ][ method ]( event, ui );
|
||||||
}
|
}
|
||||||
orig.apply( this, arguments );
|
}
|
||||||
|
|
||||||
|
return allowed;
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
@ -141,14 +143,9 @@ $.ui.droppable.tolerance = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// Pointer overlaps droppable
|
// Pointer overlaps droppable
|
||||||
// TODO: this has to use pointerPosition, not event
|
|
||||||
pointer: function( event, edges, ui ) {
|
pointer: function( event, edges, ui ) {
|
||||||
var xOverlap = event.pageX >= this.offset.left &&
|
return ui.pointer.x >= this.offset.left && ui.pointer.x <= edges.right &&
|
||||||
event.pageX <= edges.right,
|
ui.pointer.y >= this.offset.top && ui.pointer.y <= edges.bottom;
|
||||||
yOverlap = event.pageY >= this.offset.top &&
|
|
||||||
event.pageY <= edges.bottom;
|
|
||||||
|
|
||||||
return xOverlap && yOverlap;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user