Fixed trashcan flyout positioning.

This commit is contained in:
Beka Westberg
2019-03-29 08:19:24 -07:00
parent 3ff21e45b9
commit 5b25843b98
2 changed files with 40 additions and 12 deletions

View File

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

View File

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