mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Droppable: Fixed intersect tolerance.
This commit is contained in:
parent
98795e3d91
commit
d4bc923f56
32
ui/jquery.ui.droppable.js
vendored
32
ui/jquery.ui.droppable.js
vendored
@ -32,6 +32,7 @@ var guid = 0,
|
|||||||
$.widget( "ui.droppable", {
|
$.widget( "ui.droppable", {
|
||||||
version: "@VERSION",
|
version: "@VERSION",
|
||||||
widgetEventPrefix: "drop",
|
widgetEventPrefix: "drop",
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
// accept: null,
|
// accept: null,
|
||||||
// greedy: false,
|
// greedy: false,
|
||||||
@ -48,6 +49,8 @@ $.widget( "ui.droppable", {
|
|||||||
droppables[ this.guid ] = this;
|
droppables[ this.guid ] = this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** public **/
|
||||||
|
|
||||||
// TODO: rename to refresh()?
|
// TODO: rename to refresh()?
|
||||||
refreshPosition: function() {
|
refreshPosition: function() {
|
||||||
// Store current location
|
// Store current location
|
||||||
@ -61,6 +64,8 @@ $.widget( "ui.droppable", {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** draggable integration **/
|
||||||
|
|
||||||
_draggableStart: function( event, ui ) {
|
_draggableStart: function( event, ui ) {
|
||||||
var draggable = $( event.target );
|
var draggable = $( event.target );
|
||||||
|
|
||||||
@ -102,6 +107,8 @@ $.widget( "ui.droppable", {
|
|||||||
this.over = false;
|
this.over = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/** internal **/
|
||||||
|
|
||||||
// TODO: fill me out
|
// TODO: fill me out
|
||||||
_uiHash: function() {
|
_uiHash: function() {
|
||||||
return {};
|
return {};
|
||||||
@ -113,28 +120,13 @@ $.widget( "ui.droppable", {
|
|||||||
});
|
});
|
||||||
|
|
||||||
$.ui.droppable.tolerance = {
|
$.ui.droppable.tolerance = {
|
||||||
// Determines if draggable is over droppable based on intersect tolerance
|
// Half of the draggable is over the droppable, horizontally and vertically
|
||||||
// TODO: move all tolerance methods into a hash
|
|
||||||
// $.ui.droppable.tolerance.intersect
|
|
||||||
intersect: function( event, edges, ui ) {
|
intersect: function( event, edges, ui ) {
|
||||||
var xDiff = edges.draggableRight - this.offset.left,
|
var xHalf = ui.offset.left + this.draggableProportions.width / 2,
|
||||||
yDiff = edges.draggableBottom - this.offset.top,
|
yHalf = ui.offset.top + this.draggableProportions.height / 2;
|
||||||
xHalfway = this.proportions.width / 2,
|
|
||||||
yHalfway = this.proportions.height / 2,
|
|
||||||
xOverlap = false,
|
|
||||||
yOverlap = false;
|
|
||||||
|
|
||||||
// If Coming from left or right
|
return this.offset.left < xHalf && edges.right > xHalf &&
|
||||||
xOverlap = ui.offset.left < this.offset.left ?
|
this.offset.top < yHalf && edges.bottom > yHalf;
|
||||||
xDiff >= xHalfway :
|
|
||||||
xDiff <= xHalfway + this.proportions.width;
|
|
||||||
|
|
||||||
// If Coming from top or bottom
|
|
||||||
yOverlap = ui.offset.top < this.offset.top ?
|
|
||||||
yDiff >= yHalfway :
|
|
||||||
yDiff <= yHalfway + this.proportions.height;
|
|
||||||
|
|
||||||
return xOverlap && yOverlap;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Determines if draggable is over droppable based on touch tolerance
|
// Determines if draggable is over droppable based on touch tolerance
|
||||||
|
Loading…
Reference in New Issue
Block a user