From c2bf01ab4879e489b2e996eea2459d4bdf74dde6 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Wed, 19 Oct 2016 17:15:57 -0700 Subject: [PATCH] Dragging blocks towards the toolbox should create blocks rather than do nothing. --- core/flyout.js | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/core/flyout.js b/core/flyout.js index 199a34bfb..c872f9252 100644 --- a/core/flyout.js +++ b/core/flyout.js @@ -1056,34 +1056,21 @@ Blockly.Flyout.prototype.isDragTowardWorkspace_ = function(dx, dy) { // Direction goes from -180 to 180, with 0 toward the right and 90 on top. var dragDirection = Math.atan2(dy, dx) / Math.PI * 180; - var draggingTowardWorkspace = false; var range = this.dragAngleRange_; if (this.horizontalLayout_) { - if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_TOP) { - // Horizontal at top. - if (dragDirection < 90 + range && dragDirection > 90 - range) { - draggingTowardWorkspace = true; - } - } else { - // Horizontal at bottom. - if (dragDirection > -90 - range && dragDirection < -90 + range) { - draggingTowardWorkspace = true; - } + // Check for up or down dragging. + if ((dragDirection < 90 + range && dragDirection > 90 - range) || + (dragDirection > -90 - range && dragDirection < -90 + range)) { + return true; } } else { - if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_LEFT) { - // Vertical at left. - if (dragDirection < range && dragDirection > -range) { - draggingTowardWorkspace = true; - } - } else { - // Vertical at right. - if (dragDirection < -180 + range || dragDirection > 180 - range) { - draggingTowardWorkspace = true; - } + // Check for left or right dragging. + if ((dragDirection < range && dragDirection > -range) || + (dragDirection < -180 + range || dragDirection > 180 - range)) { + return true; } } - return draggingTowardWorkspace; + return false; }; /**