diff --git a/browser/base/content/tabcandy/app/drag.js b/browser/base/content/tabcandy/app/drag.js index c982ae1abbd..b35b3364a24 100644 --- a/browser/base/content/tabcandy/app/drag.js +++ b/browser/base/content/tabcandy/app/drag.js @@ -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; diff --git a/browser/base/content/tabcandy/app/items.js b/browser/base/content/tabcandy/app/items.js index 52838c0dd9c..ecda43b6f0a 100644 --- a/browser/base/content/tabcandy/app/items.js +++ b/browser/base/content/tabcandy/app/items.js @@ -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