mirror of
https://github.com/google/blockly.git
synced 2026-01-09 18:10:08 +01:00
consider the last block on the stack when looking for places to attach a dragging stack.
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user