Add overrideable function to get flyout scale (#4647)

This commit is contained in:
Maribeth Bottorff
2021-02-26 12:06:27 -08:00
committed by GitHub
parent b00db4c033
commit 4fd6d1b229
3 changed files with 11 additions and 2 deletions

View File

@@ -341,6 +341,15 @@ Blockly.Flyout.prototype.getHeight = function() {
return this.height_;
};
/**
* Get the scale (zoom level) of the flyout. By default,
* this matches the target workspace scale, but this can be overridden.
* @return {number} Flyout workspace scale.
*/
Blockly.Flyout.prototype.getFlyoutScale = function() {
return this.targetWorkspace.scale;
};
/**
* Get the workspace inside the flyout.
* @return {!Blockly.WorkspaceSvg} The workspace inside the flyout.

View File

@@ -386,7 +386,7 @@ Blockly.HorizontalFlyout.prototype.getClientRect = function() {
* @protected
*/
Blockly.HorizontalFlyout.prototype.reflowInternal_ = function() {
this.workspace_.scale = this.targetWorkspace.scale;
this.workspace_.scale = this.getFlyoutScale();
var flyoutHeight = 0;
var blocks = this.workspace_.getTopBlocks(false);
for (var i = 0, block; (block = blocks[i]); i++) {

View File

@@ -370,7 +370,7 @@ Blockly.VerticalFlyout.prototype.getClientRect = function() {
* @protected
*/
Blockly.VerticalFlyout.prototype.reflowInternal_ = function() {
this.workspace_.scale = this.targetWorkspace.scale;
this.workspace_.scale = this.getFlyoutScale();
var flyoutWidth = 0;
var blocks = this.workspace_.getTopBlocks(false);
for (var i = 0, block; (block = blocks[i]); i++) {