mirror of
https://github.com/google/blockly.git
synced 2026-01-11 02:47:09 +01:00
Fix Mutator editor block positions sometimes being out of place for an instant (#5210)
This commit is contained in:
@@ -352,6 +352,8 @@ Blockly.Mutator.prototype.setVisible = function(visible) {
|
||||
this.resizeBubble_();
|
||||
// When the mutator's workspace changes, update the source block.
|
||||
this.workspace_.addChangeListener(this.workspaceChanged_.bind(this));
|
||||
// Update the source block immediately after the bubble becomes visible.
|
||||
this.updateWorkspace_();
|
||||
this.applyColour();
|
||||
} else {
|
||||
// Dispose of the bubble.
|
||||
@@ -371,18 +373,24 @@ Blockly.Mutator.prototype.setVisible = function(visible) {
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the source block when the mutator's blocks are changed.
|
||||
* Bump down any block that's too high.
|
||||
* Fired whenever a change is made to the mutator's workspace.
|
||||
* @param {!Blockly.Events.Abstract} e Custom data for event.
|
||||
* @private
|
||||
*/
|
||||
Blockly.Mutator.prototype.workspaceChanged_ = function(e) {
|
||||
if (e.isUiEvent ||
|
||||
(e.type == Blockly.Events.CHANGE && e.element == 'disabled')) {
|
||||
return;
|
||||
if (!(e.isUiEvent ||
|
||||
(e.type == Blockly.Events.CHANGE && e.element == 'disabled') ||
|
||||
e.type == Blockly.Events.CREATE)) {
|
||||
this.updateWorkspace_();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Updates the source block when the mutator's blocks are changed.
|
||||
* Bump down any block that's too high.
|
||||
* @private
|
||||
*/
|
||||
Blockly.Mutator.prototype.updateWorkspace_ = function() {
|
||||
if (!this.workspace_.isDragging()) {
|
||||
var blocks = this.workspace_.getTopBlocks(false);
|
||||
var MARGIN = 20;
|
||||
|
||||
Reference in New Issue
Block a user