Keep a list of connections that are being dragged

This commit is contained in:
rachel-fenichel
2016-04-05 16:13:19 -07:00
parent 4e42a1b78e
commit 5c8ff88587
3 changed files with 12 additions and 9 deletions

View File

@@ -791,8 +791,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++) {
@@ -854,6 +857,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;

View File

@@ -82,6 +82,8 @@ Blockly.highlightedConnection_ = null;
*/
Blockly.localConnection_ = null;
Blockly.draggingConnections_ = [];
/**
* Contents of the local clipboard.
* @type {Element}

View File

@@ -400,15 +400,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;