mirror of
https://github.com/google/blockly.git
synced 2026-01-09 18:10:08 +01:00
Keep a list of connections that are being dragged
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -82,6 +82,8 @@ Blockly.highlightedConnection_ = null;
|
||||
*/
|
||||
Blockly.localConnection_ = null;
|
||||
|
||||
Blockly.draggingConnections_ = [];
|
||||
|
||||
/**
|
||||
* Contents of the local clipboard.
|
||||
* @type {Element}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user