mirror of
https://github.com/google/blockly.git
synced 2026-01-08 17:40:09 +01:00
@@ -332,43 +332,9 @@ Blockly.Block.prototype.lastConnectionInStack_ = function() {
|
||||
* connected should not coincidentally line up on screen.
|
||||
* @private
|
||||
*/
|
||||
// TODO: Refactor to return early in headless mode.
|
||||
Blockly.Block.prototype.bumpNeighbours_ = function() {
|
||||
if (!this.workspace) {
|
||||
return; // Deleted block.
|
||||
}
|
||||
if (Blockly.dragMode_ != Blockly.DRAG_NONE) {
|
||||
return; // Don't bump blocks during a drag.
|
||||
}
|
||||
var rootBlock = this.getRootBlock();
|
||||
if (rootBlock.isInFlyout) {
|
||||
return; // Don't move blocks around in a flyout.
|
||||
}
|
||||
// Loop through every connection on this block.
|
||||
var myConnections = this.getConnections_(false);
|
||||
for (var i = 0, connection; connection = myConnections[i]; i++) {
|
||||
// Spider down from this block bumping all sub-blocks.
|
||||
if (connection.isConnected() && connection.isSuperior()) {
|
||||
connection.targetBlock().bumpNeighbours_();
|
||||
}
|
||||
|
||||
var neighbours = connection.neighbours_(Blockly.SNAP_RADIUS);
|
||||
for (var j = 0, otherConnection; otherConnection = neighbours[j]; j++) {
|
||||
// If both connections are connected, that's probably fine. But if
|
||||
// either one of them is unconnected, then there could be confusion.
|
||||
if (!connection.isConnected() || !otherConnection.isConnected()) {
|
||||
// Only bump blocks if they are from different tree structures.
|
||||
if (otherConnection.getSourceBlock().getRootBlock() != rootBlock) {
|
||||
// Always bump the inferior block.
|
||||
if (connection.isSuperior()) {
|
||||
otherConnection.bumpAwayFrom_(connection);
|
||||
} else {
|
||||
connection.bumpAwayFrom_(otherConnection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
console.warn("Not expected to reach this bumpNeighbours_ function. The \
|
||||
BlockSvg function for bumpNeighbours_ was expected to be called instead.")
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user