Merge pull request #318 from rachel-fenichel/feature/dragged_connection_list

Keep a list of connections that are being dragged
This commit is contained in:
rachel-fenichel
2016-05-12 13:24:35 -07:00
3 changed files with 17 additions and 9 deletions

View File

@@ -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;

View File

@@ -83,6 +83,13 @@ Blockly.highlightedConnection_ = null;
*/
Blockly.localConnection_ = null;
/**
* All of the connections on blocks that are currently being dragged.
* @type {!Array.<!Blockly.Connection>}
* @private
*/
Blockly.draggingConnections_ = [];
/**
* Contents of the local clipboard.
* @type {Element}

View File

@@ -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;