Dragging blocks towards the toolbox should create blocks rather than do nothing

Recreation of commit c2bf01ab48 which got
lost in a refactor.
This commit is contained in:
Neil Fraser
2018-03-22 15:44:18 -07:00
committed by Neil Fraser
parent 300446964e
commit ec6b5c7f96
2 changed files with 8 additions and 20 deletions

View File

@@ -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;
};

View File

@@ -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;
};