don't snap to anything (except edges) if you're on top of another group (fixes bug reported by Aza: snapping onto another group)

This commit is contained in:
Michael Yoshitaka Erlewine 2010-06-22 23:16:49 -04:00
parent 81aa471969
commit d0875e4220
2 changed files with 18 additions and 1 deletions

View File

@ -100,7 +100,9 @@ Drag.prototype = {
var newRect;
// OH SNAP!
if (!Keys.meta) { // if we aren't holding down the meta key...
if ( !Keys.meta // if we aren't holding down the meta key...
&& !this.item.overlapsWithOtherItems() // and we aren't on top of anything else...
) {
newRect = Trenches.snap(bounds,assumeConstantSize,keepProportional);
if (newRect) { // might be false if no changes were made
update = true;

View File

@ -237,6 +237,21 @@ window.Item.prototype = {
Utils.assert('this.bounds', isRect(this.bounds));
return new Rect(this.bounds);
},
// ----------
// Function: overlapsWithOtherItems
// Returns true if this Item overlaps with any other Item on the screen.
overlapsWithOtherItems: function() {
var self = this;
var items = Items.getTopLevelItems();
var bounds = this.getBounds();
return items.some(function(item) {
if (item == self) // can't overlap with yourself.
return false;
var myBounds = item.getBounds();
return myBounds.intersects(bounds);
} );
},
// ----------
// Function: setPosition