Stop bumping neighbours in headless blockly

This commit is contained in:
Rachel Fenichel
2017-01-27 11:33:04 -08:00
parent b530f73747
commit 2474ec53ab
2 changed files with 27 additions and 7 deletions

View File

@@ -571,6 +571,18 @@ Blockly.Connection.prototype.checkType_ = function(otherConnection) {
return false;
};
/**
* Function to be called when this connection's compatible types have changed.
* @private
*/
Blockly.Connection.prototype.onCheckChanged_ = function() {
// The new value type may not be compatible with the existing connection.
if (this.isConnected() && !this.checkType_(this.targetConnection)) {
var child = this.isSuperior() ? this.targetBlock() : this.sourceBlock_;
child.unplug();
}
};
/**
* Change a connection's compatibility.
* @param {*} check Compatible value type or list of value types.
@@ -585,13 +597,7 @@ Blockly.Connection.prototype.setCheck = function(check) {
check = [check];
}
this.check_ = check;
// The new value type may not be compatible with the existing connection.
if (this.isConnected() && !this.checkType_(this.targetConnection)) {
var child = this.isSuperior() ? this.targetBlock() : this.sourceBlock_;
child.unplug();
// Bump away.
this.sourceBlock_.bumpNeighbours_();
}
this.onCheckChanged_();
} else {
this.check_ = null;
}

View File

@@ -393,3 +393,17 @@ Blockly.RenderedConnection.prototype.connect_ = function(childConnection) {
}
}
};
/**
* Function to be called when this connection's compatible types have changed.
* @private
*/
Blockly.RenderedConnection.prototype.onCheckChanged_ = function() {
// The new value type may not be compatible with the existing connection.
if (this.isConnected() && !this.checkType_(this.targetConnection)) {
var child = this.isSuperior() ? this.targetBlock() : this.sourceBlock_;
child.unplug();
// Bump away.
this.sourceBlock_.bumpNeighbours_();
}
};