From ec6b5c7f960a2e1d4066861e7560ab623b0c8958 Mon Sep 17 00:00:00 2001 From: Neil Fraser Date: Thu, 22 Mar 2018 15:44:18 -0700 Subject: [PATCH] Dragging blocks towards the toolbox should create blocks rather than do nothing Recreation of commit c2bf01ab4879e489b2e996eea2459d4bdf74dde6 which got lost in a refactor. --- core/flyout_horizontal.js | 14 ++++---------- core/flyout_vertical.js | 14 ++++---------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/core/flyout_horizontal.js b/core/flyout_horizontal.js index 7268e9bee..9243c0ef7 100644 --- a/core/flyout_horizontal.js +++ b/core/flyout_horizontal.js @@ -309,16 +309,10 @@ Blockly.HorizontalFlyout.prototype.isDragTowardWorkspace = function( var dragDirection = Math.atan2(dy, dx) / Math.PI * 180; var range = this.dragAngleRange_; - if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_TOP) { - // Horizontal at top. - if (dragDirection < 90 + range && dragDirection > 90 - range) { - return true; - } - } else { - // Horizontal at bottom. - if (dragDirection > -90 - range && dragDirection < -90 + range) { - return true; - } + // Check for up or down dragging. + if ((dragDirection < 90 + range && dragDirection > 90 - range) || + (dragDirection > -90 - range && dragDirection < -90 + range)) { + return true; } return false; }; diff --git a/core/flyout_vertical.js b/core/flyout_vertical.js index 5559c43d9..968d01c78 100644 --- a/core/flyout_vertical.js +++ b/core/flyout_vertical.js @@ -286,16 +286,10 @@ Blockly.VerticalFlyout.prototype.isDragTowardWorkspace = function( var dragDirection = Math.atan2(dy, dx) / Math.PI * 180; var range = this.dragAngleRange_; - if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_LEFT) { - // Vertical at left. - if (dragDirection < range && dragDirection > -range) { - return true; - } - } else { - // Vertical at right. - if (dragDirection < -180 + range || dragDirection > 180 - range) { - return true; - } + // Check for left or right dragging. + if ((dragDirection < range && dragDirection > -range) || + (dragDirection < -180 + range || dragDirection > 180 - range)) { + return true; } return false; };