diff --git a/core/block_svg.js b/core/block_svg.js index db55c5a60..745d58b65 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -813,8 +813,11 @@ Blockly.BlockSvg.prototype.setDragging_ = function(adding) { group.translate_ = ''; group.skew_ = ''; this.addDragging(); + Blockly.draggingConnections_ = + Blockly.draggingConnections_.concat(this.getConnections_(true)); } else { this.removeDragging(); + Blockly.draggingConnections_ = []; } // Recurse through all blocks attached under this one. for (var i = 0; i < this.childBlocks_.length; i++) { @@ -875,6 +878,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; diff --git a/core/blockly.js b/core/blockly.js index 822c75f4e..17e24966f 100644 --- a/core/blockly.js +++ b/core/blockly.js @@ -83,6 +83,13 @@ Blockly.highlightedConnection_ = null; */ Blockly.localConnection_ = null; +/** + * All of the connections on blocks that are currently being dragged. + * @type {!Array.} + * @private + */ +Blockly.draggingConnections_ = []; + /** * Contents of the local clipboard. * @type {Element} diff --git a/core/connection.js b/core/connection.js index 84c35dd93..c52280464 100644 --- a/core/connection.js +++ b/core/connection.js @@ -367,15 +367,8 @@ Blockly.Connection.prototype.isConnectionAllowed = function(candidate) { } // Don't let blocks try to connect to themselves or ones they nest. - var targetSourceBlock = candidate.getSourceBlock(); - var sourceBlock = this.sourceBlock_; - if (targetSourceBlock && sourceBlock) { - do { - if (sourceBlock == targetSourceBlock) { - return false; - } - targetSourceBlock = targetSourceBlock.getParent(); - } while (targetSourceBlock); + if (Blockly.draggingConnections_.indexOf(candidate) != -1) { + return false; } return true;