mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
+ If a dragged item overlaps more than one droppable, the largest intersection wins
+ Added intersection and area to Rect + Cleaned out a little debug code
This commit is contained in:
parent
3c78dad6c8
commit
922535a30a
@ -1035,9 +1035,7 @@ window.Group.prototype = iQ.extend(new Item(), new Subscribable(), {
|
||||
Groups.setActiveGroup(self);
|
||||
return { shouldZoom: true };
|
||||
}*/
|
||||
|
||||
Utils.log("SHOULD EXPAND?", child)
|
||||
|
||||
|
||||
Groups.setActiveGroup(self);
|
||||
return { shouldZoom: true };
|
||||
|
||||
|
@ -597,9 +597,14 @@ window.Item.prototype = {
|
||||
self.dragOptions.drag.apply(self, [e, {position: box.position()}]);
|
||||
|
||||
// drop events
|
||||
var newDropTarget = null;
|
||||
var best = {
|
||||
dropTarget: null,
|
||||
score: 0
|
||||
};
|
||||
|
||||
iQ.each(droppables, function(index, droppable) {
|
||||
if(box.intersects(droppable.bounds)) {
|
||||
var intersection = box.intersection(droppable.bounds);
|
||||
if(intersection && intersection.area() > best.score) {
|
||||
var possibleDropTarget = droppable.item;
|
||||
var accept = true;
|
||||
if(possibleDropTarget != dropTarget) {
|
||||
@ -609,13 +614,13 @@ window.Item.prototype = {
|
||||
}
|
||||
|
||||
if(accept) {
|
||||
newDropTarget = possibleDropTarget;
|
||||
return false;
|
||||
best.dropTarget = possibleDropTarget;
|
||||
best.score = intersection.area();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if(newDropTarget != dropTarget) {
|
||||
if(best.dropTarget != dropTarget) {
|
||||
var dropOptions;
|
||||
if(dropTarget) {
|
||||
dropOptions = dropTarget.dropOptions;
|
||||
@ -623,7 +628,7 @@ window.Item.prototype = {
|
||||
dropOptions.out.apply(dropTarget, [e]);
|
||||
}
|
||||
|
||||
dropTarget = newDropTarget;
|
||||
dropTarget = best.dropTarget;
|
||||
|
||||
if(dropTarget) {
|
||||
dropOptions = dropTarget.dropOptions;
|
||||
|
@ -144,10 +144,12 @@ window.Rect.prototype = {
|
||||
this.height = value - this.top;
|
||||
},
|
||||
|
||||
// ----------
|
||||
get xRange() {
|
||||
return new Range(this.left,this.right);
|
||||
},
|
||||
|
||||
// ----------
|
||||
get yRange() {
|
||||
return new Range(this.top,this.bottom);
|
||||
},
|
||||
@ -160,6 +162,17 @@ window.Rect.prototype = {
|
||||
&& rect.top < this.bottom);
|
||||
},
|
||||
|
||||
// ----------
|
||||
intersection: function(rect) {
|
||||
var box = new Rect(Math.max(rect.left, this.left), Math.max(rect.top, this.top), 0, 0);
|
||||
box.right = Math.min(rect.right, this.right);
|
||||
box.bottom = Math.min(rect.bottom, this.bottom);
|
||||
if(box.width > 0 && box.height > 0)
|
||||
return box;
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
// ----------
|
||||
// Function: containsPoint
|
||||
// Returns a boolean denoting if the <Point> is inside of
|
||||
@ -193,6 +206,7 @@ window.Rect.prototype = {
|
||||
return new Point(this.left + (this.width / 2), this.top + (this.height / 2));
|
||||
},
|
||||
|
||||
// ----------
|
||||
size: function() {
|
||||
return new Point(this.width, this.height);
|
||||
},
|
||||
@ -202,6 +216,11 @@ window.Rect.prototype = {
|
||||
return new Point(this.left, this.top);
|
||||
},
|
||||
|
||||
// ----------
|
||||
area: function() {
|
||||
return this.width * this.height;
|
||||
},
|
||||
|
||||
// ----------
|
||||
// Function: inset
|
||||
// Makes the rect smaller (if the arguments are positive) as if a margin is added all around
|
||||
|
Loading…
Reference in New Issue
Block a user