mirror of
https://github.com/google/blockly.git
synced 2026-01-09 10:00:09 +01:00
Fix duplicated stacks of collapsed connected blocks.
This commit is contained in:
@@ -273,12 +273,12 @@ Blockly.Block.prototype.getConnections_ = function(all) {
|
||||
if (this.outputConnection) {
|
||||
myConnections.push(this.outputConnection);
|
||||
}
|
||||
if (this.nextConnection) {
|
||||
myConnections.push(this.nextConnection);
|
||||
}
|
||||
if (this.previousConnection) {
|
||||
myConnections.push(this.previousConnection);
|
||||
}
|
||||
if (this.nextConnection) {
|
||||
myConnections.push(this.nextConnection);
|
||||
}
|
||||
if (all || !this.collapsed_) {
|
||||
for (var i = 0, input; input = this.inputList[i]; i++) {
|
||||
if (input.connection) {
|
||||
@@ -518,18 +518,30 @@ Blockly.Block.prototype.setEditable = function(editable) {
|
||||
* @param {boolean} hidden True if connections are hidden.
|
||||
*/
|
||||
Blockly.Block.prototype.setConnectionsHidden = function(hidden) {
|
||||
var myConnections = this.getConnections_(true);
|
||||
for (var i = 0, connection; connection = myConnections[i]; i++) {
|
||||
if (connection.isSuperior()) {
|
||||
if (!this.isCollapsed()) {
|
||||
connection.setHidden(hidden);
|
||||
if (!hidden && this.isCollapsed()) {
|
||||
if (this.outputConnection) {
|
||||
this.outputConnection.setHidden(hidden);
|
||||
}
|
||||
if (this.previousConnection) {
|
||||
this.previousConnection.setHidden(hidden);
|
||||
}
|
||||
if (this.nextConnection) {
|
||||
this.nextConnection.setHidden(hidden);
|
||||
var child = this.nextConnection.targetBlock();
|
||||
if (child) {
|
||||
child.setConnectionsHidden(hidden);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var myConnections = this.getConnections_(true);
|
||||
for (var i = 0, connection; connection = myConnections[i]; i++) {
|
||||
connection.setHidden(hidden);
|
||||
if (connection.isSuperior()) {
|
||||
var child = connection.targetBlock();
|
||||
if (child) {
|
||||
child.setConnectionsHidden(hidden);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
connection.setHidden(hidden);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -666,9 +666,8 @@ Blockly.Connection.prototype.hideAll = function() {
|
||||
* @return {!Array.<!Blockly.Block>} List of blocks to render.
|
||||
*/
|
||||
Blockly.Connection.prototype.unhideAll = function() {
|
||||
if (!this.hidden_) {
|
||||
this.dbList_[this.type].addConnection_(this);
|
||||
}
|
||||
this.dbList_[this.type].addConnection_(this);
|
||||
this.hidden_ = false;
|
||||
// All blocks that need unhiding must be unhidden before any rendering takes
|
||||
// place, since rendering requires knowing the dimensions of lower blocks.
|
||||
// Also, since rendering a block renders all its parents, we only need to
|
||||
|
||||
Reference in New Issue
Block a user