Ignore mouseup at end of drag with isDragging (#416)

This includes both block drags and workspace scrolls and fixes #404. I
used isDragging rather than checking the origin of click so that it can
easily be extended to the case where the flyout is scrolled by dragging
a block, a la LLK/scratch-blocks#206.
This commit is contained in:
Rodrigo Queiro
2016-06-29 03:11:48 +02:00
committed by Neil Fraser
parent ff90218c07
commit 2dcb6cb68b
4 changed files with 11 additions and 4 deletions

View File

@@ -433,7 +433,7 @@ Blockly.Field.prototype.onMouseUp_ = function(e) {
} else if (Blockly.isRightButton(e)) {
// Right-click.
return;
} else if (Blockly.dragMode_ == Blockly.DRAG_FREE) {
} else if (this.sourceBlock_.workspace.isDragging()) {
// Drag operation is concluding. Don't open the editor.
return;
} else if (this.sourceBlock_.isEditable()) {

View File

@@ -761,8 +761,7 @@ Blockly.Flyout.prototype.onMouseDown_ = function(e) {
* @private
*/
Blockly.Flyout.prototype.onMouseUp_ = function(e) {
if (Blockly.dragMode_ != Blockly.DRAG_FREE &&
!Blockly.WidgetDiv.isVisible()) {
if (!this.workspace_.isDragging() && !Blockly.WidgetDiv.isVisible()) {
Blockly.Events.fire(
new Blockly.Events.Ui(Blockly.Flyout.startBlock_, 'click',
undefined, undefined));

View File

@@ -124,7 +124,7 @@ Blockly.Icon.prototype.isVisible = function() {
* @private
*/
Blockly.Icon.prototype.iconClick_ = function(e) {
if (Blockly.dragMode_ == Blockly.DRAG_FREE) {
if (this.block_.workspace.isDragging()) {
// Drag operation is concluding. Don't open the editor.
return;
}

View File

@@ -710,6 +710,14 @@ Blockly.WorkspaceSvg.prototype.moveDrag = function(e) {
return goog.math.Coordinate.sum(this.dragDeltaXY_, point);
};
/**
* Is the user currently dragging a block or scrolling the workspace?
* @return {boolean} True if currently dragging or scrolling
*/
Blockly.WorkspaceSvg.prototype.isDragging = function() {
return Blockly.dragMode_ == Blockly.DRAG_FREE || this.isScrolling;
};
/**
* Handle a mouse-wheel on SVG drawing surface.
* @param {!Event} e Mouse wheel event.