From 1f6c8f02065742ec02200d02b2feb91492b9a963 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Fri, 18 Jun 2021 20:26:17 +0000 Subject: [PATCH 1/3] Reflow flyouts when zoom level changes to keep block zoom level in sync. --- core/flyout_base.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/core/flyout_base.js b/core/flyout_base.js index 84d6d3870..96ac19c46 100644 --- a/core/flyout_base.js +++ b/core/flyout_base.js @@ -296,6 +296,9 @@ Blockly.Flyout.prototype.init = function(targetWorkspace) { this.targetWorkspace.addChangeListener(this.filterWrapper_); } + var zoomHandler = this.handleZoom_.bind(this); + this.targetWorkspace.addChangeListener(zoomHandler); + // Dragging the flyout up and down. Array.prototype.push.apply( this.eventWrappers_, @@ -960,6 +963,19 @@ Blockly.Flyout.prototype.filterForCapacity_ = function() { } }; +/** + * Responds to workplace zoom events by reflowing the flyout to ensure that + * blocks in the flyout adjust to the new zoom level. + * @param {!Blockly.Events.Abstract} event The Blockly event that was fired. + * @private + */ +Blockly.Flyout.prototype.handleZoom_ = function(event) { + if (event.type === Blockly.Events.CLICK && + event.targetType === 'zoom_controls') { + this.reflow(); + } +}; + /** * Reflow blocks and their mats. */ From 0d44d2262975179f020e2fd590635349c6f5b2c6 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Mon, 28 Jun 2021 10:48:36 -0700 Subject: [PATCH 2/3] Revert "Reflow flyouts when zoom level changes to keep block zoom level in sync." This reverts commit 1f6c8f02065742ec02200d02b2feb91492b9a963. --- core/flyout_base.js | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/core/flyout_base.js b/core/flyout_base.js index 96ac19c46..84d6d3870 100644 --- a/core/flyout_base.js +++ b/core/flyout_base.js @@ -296,9 +296,6 @@ Blockly.Flyout.prototype.init = function(targetWorkspace) { this.targetWorkspace.addChangeListener(this.filterWrapper_); } - var zoomHandler = this.handleZoom_.bind(this); - this.targetWorkspace.addChangeListener(zoomHandler); - // Dragging the flyout up and down. Array.prototype.push.apply( this.eventWrappers_, @@ -963,19 +960,6 @@ Blockly.Flyout.prototype.filterForCapacity_ = function() { } }; -/** - * Responds to workplace zoom events by reflowing the flyout to ensure that - * blocks in the flyout adjust to the new zoom level. - * @param {!Blockly.Events.Abstract} event The Blockly event that was fired. - * @private - */ -Blockly.Flyout.prototype.handleZoom_ = function(event) { - if (event.type === Blockly.Events.CLICK && - event.targetType === 'zoom_controls') { - this.reflow(); - } -}; - /** * Reflow blocks and their mats. */ From 627647c7f2cc19ec89479ff8cd788ec56e73ecdd Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Mon, 28 Jun 2021 11:08:03 -0700 Subject: [PATCH 3/3] Reflow workspace- and toolbox-owned flyouts when workspace zoom changes. --- core/workspace_svg.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/workspace_svg.js b/core/workspace_svg.js index 95618dbef..8f9590d1e 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -2225,9 +2225,10 @@ Blockly.WorkspaceSvg.prototype.setScale = function(newScale) { this.scale = newScale; Blockly.hideChaff(false); - if (this.flyout_) { - // No toolbox, resize flyout. - this.flyout_.reflow(); + // Get the flyout, if any, whether our own or owned by the toolbox. + var flyout = this.getFlyout(false); + if (flyout && flyout.isVisible()) { + flyout.reflow(); this.recordDragTargets(); } if (this.grid_) {