mirror of
https://github.com/scratchfoundation/scratch-blocks.git
synced 2025-08-28 22:10:31 -04:00
Fix for #521.
Add a isMutator member similar to isFlyout to workspace_svg so it knows whether it is mutator or not. Allow blocks to access that property so that they can recalculate coordinates appropriately.
This commit is contained in:
parent
f6f39c48f5
commit
33e9d75457
4 changed files with 17 additions and 0 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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_();
|
||||
|
|
|
@ -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_;
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue