consider the last block on the stack when looking for places to attach a dragging stack.

This commit is contained in:
rachel-fenichel
2016-03-11 18:07:26 -08:00
parent 06ff90bcaf
commit 74ea1f1ffe
2 changed files with 24 additions and 0 deletions

View File

@@ -278,6 +278,25 @@ Blockly.Block.prototype.getConnections_ = function(all) {
return myConnections;
};
/**
* Walks down a stack of blocks and finds the last next connection on the stack.
* @return {Blockly.Connection} The last next connection on the stack, or null.
* @private
*/
Blockly.Block.prototype.lastConnectionInStack_ = function() {
var nextConnection = this.nextConnection;
while (nextConnection) {
var nextBlock = nextConnection.targetBlock();
if (!nextBlock) {
// Found a next connection with nothing on the other side.
return nextConnection;
}
nextConnection = nextBlock.nextConnection;
}
// Ran out of next connections.
return null;
};
/**
* Bump unconnected blocks out of alignment. Two blocks which aren't actually
* connected should not coincidentally line up on screen.

View File

@@ -822,6 +822,11 @@ Blockly.BlockSvg.prototype.onMouseMove_ = function(e) {
// Check to see if any of this block's connections are within range of
// another block's connection.
var myConnections = this.getConnections_(false);
// Also check the last connection on this stack
var lastOnStack = this.lastConnectionInStack_();
if (lastOnStack && lastOnStack != this.nextConnection) {
myConnections.push(lastOnStack);
}
var closestConnection = null;
var localConnection = null;
var radiusConnection = Blockly.SNAP_RADIUS;