mirror of
https://github.com/google/blockly.git
synced 2026-01-25 09:40:10 +01:00
Slightly less fragile
This commit is contained in:
@@ -482,11 +482,24 @@ Blockly.blockRendering.InputRow.prototype.measure = function() {
|
||||
this.widthWithConnectedBlocks = this.width + connectedBlockWidths;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @override
|
||||
*/
|
||||
Blockly.blockRendering.InputRow.prototype.getLastSpacer = function() {
|
||||
// Adding spacing after the input connection would look weird. Find the
|
||||
// before the last input connection and add it there instead.
|
||||
if (this.hasExternalInput || this.hasStatement) {
|
||||
var spacer = this.elements[this.elements.length - 3];
|
||||
return /** @type {Blockly.blockRendering.InRowSpacer} */ (spacer);
|
||||
var elems = this.elements;
|
||||
for (var i = elems.length - 1, elem; (elem = elems[i]); i--) {
|
||||
if (elem.isSpacer()) {
|
||||
continue;
|
||||
}
|
||||
if (elem.isInput) {
|
||||
var spacer = elems[i - 1];
|
||||
return /** @type {Blockly.blockRendering.InRowSpacer} */ (spacer);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return Blockly.blockRendering.InputRow.superClass_.getLastSpacer.call(this);
|
||||
};
|
||||
|
||||
@@ -253,14 +253,12 @@ Blockly.thrasos.RenderInfo.prototype.alignRowElements_ = function() {
|
||||
* @override
|
||||
*/
|
||||
Blockly.thrasos.RenderInfo.prototype.addAlignmentPadding_ = function(row, missingSpace) {
|
||||
var elems = row.elements;
|
||||
var input = row.getLastInput();
|
||||
if (input) {
|
||||
var firstSpacer = row.getFirstSpacer();
|
||||
var lastSpacer = row.getLastSpacer();
|
||||
if (row.hasExternalInput || row.hasStatement) {
|
||||
// Get the spacer right before the input socket.
|
||||
lastSpacer = elems[elems.length - 3];
|
||||
row.widthWithConnectedBlocks += missingSpace;
|
||||
}
|
||||
// Decide where the extra padding goes.
|
||||
|
||||
Reference in New Issue
Block a user