diff --git a/core/block.js b/core/block.js index 0bace4292..a6986f7d5 100644 --- a/core/block.js +++ b/core/block.js @@ -127,6 +127,9 @@ Blockly.Block = function(workspace, prototypeName, opt_id) { this.workspace = workspace; /** @type {boolean} */ this.isInFlyout = workspace.isFlyout; + /** @type {boolean} */ + this.isInMutator = workspace.isMutator; + /** @type {boolean} */ this.RTL = workspace.RTL; diff --git a/core/block_svg.js b/core/block_svg.js index 719c967e5..656b61596 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -533,6 +533,12 @@ Blockly.BlockSvg.prototype.onMouseDown_ = function(e) { if (this.isInFlyout) { return; } + if (this.isInMutator) { + // Mutator's coordinate system could be out of date because the bubble was + // dragged, the block was moved, the parent workspace zoomed, etc. + this.workspace.resize(); + } + this.workspace.updateScreenCalculationsIfScrolled(); this.workspace.markFocused(); Blockly.terminateDrag_(); diff --git a/core/mutator.js b/core/mutator.js index d5cca45e5..19a0fe86b 100644 --- a/core/mutator.js +++ b/core/mutator.js @@ -129,6 +129,7 @@ Blockly.Mutator.prototype.createEditor_ = function() { setMetrics: null }; this.workspace_ = new Blockly.WorkspaceSvg(workspaceOptions); + this.workspace_.isMutator = true; this.svgDialog_.appendChild( this.workspace_.createDom('blocklyMutatorBackground')); return this.svgDialog_; diff --git a/core/workspace_svg.js b/core/workspace_svg.js index ff1476e78..9148c8338 100644 --- a/core/workspace_svg.js +++ b/core/workspace_svg.js @@ -82,6 +82,13 @@ Blockly.WorkspaceSvg.prototype.rendered = true; */ Blockly.WorkspaceSvg.prototype.isFlyout = false; +/** + * Is this workspace the surface for a mutator? + * @type {boolean} + * @package + */ +Blockly.WorkspaceSvg.prototype.isMutator = false; + /** * Is this workspace currently being dragged around? * DRAG_NONE - No drag operation.