From 5b25843b9855ea6a0173c01314f73ae99dad44d4 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Fri, 29 Mar 2019 08:19:24 -0700 Subject: [PATCH] Fixed trashcan flyout positioning. --- core/flyout_horizontal.js | 26 ++++++++++++++++++++------ core/flyout_vertical.js | 26 ++++++++++++++++++++------ 2 files changed, 40 insertions(+), 12 deletions(-) diff --git a/core/flyout_horizontal.js b/core/flyout_horizontal.js index 008d9ecd0..bcb0638b3 100644 --- a/core/flyout_horizontal.js +++ b/core/flyout_horizontal.js @@ -154,18 +154,32 @@ Blockly.HorizontalFlyout.prototype.position = function() { // X is always 0 since this is a horizontal flyout. var x = 0; - // If there is a toolbox. - if (targetWorkspaceMetrics.toolboxHeight) { - if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_TOP) { - var y = targetWorkspaceMetrics.toolboxHeight; + // If this flyout is the toolbox flyout. + if (targetWorkspaceMetrics.toolboxPosition == this.toolboxPosition_) { + // If there is a toolbox. + if (targetWorkspaceMetrics.toolboxHeight) { + if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_TOP) { + var y = targetWorkspaceMetrics.toolboxHeight; + } else { + var y = targetWorkspaceMetrics.viewHeight - this.height_; + } } else { - var y = targetWorkspaceMetrics.viewHeight - this.height_; + if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_TOP) { + var y = 0; + } else { + var y = targetWorkspaceMetrics.viewHeight; + } } } else { if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_TOP) { var y = 0; } else { - var y = targetWorkspaceMetrics.viewHeight; + // Because the anchor point of the flyout is on the top, but we want + // to align the bottom edge of the flyout with the bottom edge of the + // blocklyDiv, we calculate the full height of the div minus the height + // of the flyout. + var y = targetWorkspaceMetrics.viewHeight + + targetWorkspaceMetrics.absoluteTop - this.height_; } } this.positionAt_(this.width_, this.height_, x, y); diff --git a/core/flyout_vertical.js b/core/flyout_vertical.js index a6b10ba65..abc8036b7 100644 --- a/core/flyout_vertical.js +++ b/core/flyout_vertical.js @@ -151,18 +151,32 @@ Blockly.VerticalFlyout.prototype.position = function() { // Y is always 0 since this is a vertical flyout. var y = 0; - // If there is a toolbox. - if (targetWorkspaceMetrics.toolboxWidth) { - if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_LEFT) { - var x = targetWorkspaceMetrics.toolboxWidth; + // If this flyout is the toolbox flyout. + if (targetWorkspaceMetrics.toolboxPosition == this.toolboxPosition_) { + // If there is a category toolbox. + if (targetWorkspaceMetrics.toolboxWidth) { + if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_LEFT) { + var x = targetWorkspaceMetrics.toolboxWidth; + } else { + var x = targetWorkspaceMetrics.viewWidth - this.width_; + } } else { - var x = targetWorkspaceMetrics.viewWidth - this.width_; + if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_LEFT) { + var x = 0; + } else { + var x = targetWorkspaceMetrics.viewWidth; + } } } else { if (this.toolboxPosition_ == Blockly.TOOLBOX_AT_LEFT) { var x = 0; } else { - var x = targetWorkspaceMetrics.viewWidth; + // Because the anchor point of the flyout is on the left, but we want + // to align the right edge of the flyout with the right edge of the + // blocklyDiv, we calculate the full width of the div minus the width + // of the flyout. + var x = targetWorkspaceMetrics.viewWidth + + targetWorkspaceMetrics.absoluteLeft - this.width_; } } this.positionAt_(this.width_, this.height_, x, y);