Bug 580412 - Add a couple-pixel threshold before tabs start dragging [r=dietrich, a=beltzner]
This commit is contained in:
@@ -118,8 +118,8 @@ Drag.prototype = {
|
||||
|
||||
// OH SNAP!
|
||||
|
||||
// if we aren't holding down the meta key...
|
||||
if (!Keys.meta) {
|
||||
// if we aren't holding down the meta key or have trenches disabled...
|
||||
if (!Keys.meta && !Trenches.disabled) {
|
||||
// snappable = true if we aren't a tab on top of something else, and
|
||||
// there's no active drop site...
|
||||
let snappable = !(this.item.isATabItem &&
|
||||
|
||||
@@ -187,7 +187,10 @@ Item.prototype = {
|
||||
stop: function() {
|
||||
drag.info.stop();
|
||||
drag.info = null;
|
||||
}
|
||||
},
|
||||
// The minimum the mouse must move after mouseDown in order to move an
|
||||
// item
|
||||
minDragDistance: 3
|
||||
};
|
||||
|
||||
// ___ drop
|
||||
@@ -592,64 +595,67 @@ Item.prototype = {
|
||||
// ___ mousemove
|
||||
var handleMouseMove = function(e) {
|
||||
// positioning
|
||||
var mouse = new Point(e.pageX, e.pageY);
|
||||
var box = self.getBounds();
|
||||
box.left = startPos.x + (mouse.x - startMouse.x);
|
||||
box.top = startPos.y + (mouse.y - startMouse.y);
|
||||
|
||||
self.setBounds(box, true);
|
||||
|
||||
// drag events
|
||||
var mouse = new Point(e.pageX, e.pageY);
|
||||
if (!startSent) {
|
||||
if (typeof self.dragOptions.start == "function")
|
||||
self.dragOptions.start.apply(self,
|
||||
[startEvent, {position: {left: startPos.x, top: startPos.y}}]);
|
||||
|
||||
startSent = true;
|
||||
if(Math.abs(mouse.x - startMouse.x) > self.dragOptions.minDragDistance ||
|
||||
Math.abs(mouse.y - startMouse.y) > self.dragOptions.minDragDistance) {
|
||||
if (typeof self.dragOptions.start == "function")
|
||||
self.dragOptions.start.apply(self,
|
||||
[startEvent, {position: {left: startPos.x, top: startPos.y}}]);
|
||||
startSent = true;
|
||||
}
|
||||
}
|
||||
if (startSent) {
|
||||
// drag events
|
||||
var box = self.getBounds();
|
||||
box.left = startPos.x + (mouse.x - startMouse.x);
|
||||
box.top = startPos.y + (mouse.y - startMouse.y);
|
||||
|
||||
if (typeof self.dragOptions.drag == "function")
|
||||
self.dragOptions.drag.apply(self, [e]);
|
||||
self.setBounds(box, true);
|
||||
|
||||
// drop events
|
||||
var best = {
|
||||
dropTarget: null,
|
||||
score: 0
|
||||
};
|
||||
if (typeof self.dragOptions.drag == "function")
|
||||
self.dragOptions.drag.apply(self, [e]);
|
||||
|
||||
droppables.forEach(function(droppable) {
|
||||
var intersection = box.intersection(droppable.bounds);
|
||||
if (intersection && intersection.area() > best.score) {
|
||||
var possibleDropTarget = droppable.item;
|
||||
var accept = true;
|
||||
if (possibleDropTarget != dropTarget) {
|
||||
var dropOptions = possibleDropTarget.dropOptions;
|
||||
if (dropOptions && typeof dropOptions.accept == "function")
|
||||
accept = dropOptions.accept.apply(possibleDropTarget, [self]);
|
||||
// drop events
|
||||
var best = {
|
||||
dropTarget: null,
|
||||
score: 0
|
||||
};
|
||||
|
||||
droppables.forEach(function(droppable) {
|
||||
var intersection = box.intersection(droppable.bounds);
|
||||
if (intersection && intersection.area() > best.score) {
|
||||
var possibleDropTarget = droppable.item;
|
||||
var accept = true;
|
||||
if (possibleDropTarget != dropTarget) {
|
||||
var dropOptions = possibleDropTarget.dropOptions;
|
||||
if (dropOptions && typeof dropOptions.accept == "function")
|
||||
accept = dropOptions.accept.apply(possibleDropTarget, [self]);
|
||||
}
|
||||
|
||||
if (accept) {
|
||||
best.dropTarget = possibleDropTarget;
|
||||
best.score = intersection.area();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (best.dropTarget != dropTarget) {
|
||||
var dropOptions;
|
||||
if (dropTarget) {
|
||||
dropOptions = dropTarget.dropOptions;
|
||||
if (dropOptions && typeof dropOptions.out == "function")
|
||||
dropOptions.out.apply(dropTarget, [e]);
|
||||
}
|
||||
|
||||
if (accept) {
|
||||
best.dropTarget = possibleDropTarget;
|
||||
best.score = intersection.area();
|
||||
dropTarget = best.dropTarget;
|
||||
|
||||
if (dropTarget) {
|
||||
dropOptions = dropTarget.dropOptions;
|
||||
if (dropOptions && typeof dropOptions.over == "function")
|
||||
dropOptions.over.apply(dropTarget, [e]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (best.dropTarget != dropTarget) {
|
||||
var dropOptions;
|
||||
if (dropTarget) {
|
||||
dropOptions = dropTarget.dropOptions;
|
||||
if (dropOptions && typeof dropOptions.out == "function")
|
||||
dropOptions.out.apply(dropTarget, [e]);
|
||||
}
|
||||
|
||||
dropTarget = best.dropTarget;
|
||||
|
||||
if (dropTarget) {
|
||||
dropOptions = dropTarget.dropOptions;
|
||||
if (dropOptions && typeof dropOptions.over == "function")
|
||||
dropOptions.over.apply(dropTarget, [e]);
|
||||
}
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
@@ -466,9 +466,11 @@ var Trenches = {
|
||||
// nextId - (integer) a counter for the next <Trench>'s <Trench.id> value.
|
||||
// showDebug - (boolean) whether to draw the <Trench>es or not.
|
||||
// defaultRadius - (integer) the default radius for new <Trench>es.
|
||||
// disabled - (boolean) whether trench-snapping is disabled or not.
|
||||
nextId: 0,
|
||||
showDebug: false,
|
||||
defaultRadius: 10,
|
||||
disabled: false,
|
||||
|
||||
// ---------
|
||||
// Variables: snapping preferences; used to break ties in snapping.
|
||||
|
||||
@@ -45,6 +45,7 @@ include $(topsrcdir)/config/rules.mk
|
||||
|
||||
_BROWSER_FILES = \
|
||||
browser_tabview_apptabs.js \
|
||||
browser_tabview_bug580412.js \
|
||||
browser_tabview_bug587040.js \
|
||||
browser_tabview_bug587990.js \
|
||||
browser_tabview_bug591706.js \
|
||||
|
||||
Reference in New Issue
Block a user