mirror of
https://github.com/google/blockly.git
synced 2026-01-08 09:30:06 +01:00
committed by
Sam El-Husseini
parent
6d8f22f39a
commit
c00ee908e4
@@ -1694,10 +1694,11 @@ Blockly.BlockSvg.prototype.scheduleSnapAndBump = function() {
|
||||
* Position a block so that it doesn't move the target block when connected.
|
||||
* The block to position is usually either the first block in a dragged stack or
|
||||
* an insertion marker.
|
||||
* @param {!Blockly.Connection} sourceConnection The connection on the moving
|
||||
* block's stack.
|
||||
* @param {!Blockly.Connection} targetConnection The connection that should stay
|
||||
* stationary as this block is positioned.
|
||||
* @param {!Blockly.RenderedConnection} sourceConnection The connection on the
|
||||
* moving block's stack.
|
||||
* @param {!Blockly.RenderedConnection} targetConnection The connection that
|
||||
* should stay stationary as this block is positioned.
|
||||
* @package
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.positionNearConnection = function(sourceConnection,
|
||||
targetConnection) {
|
||||
@@ -1837,32 +1838,6 @@ Blockly.BlockSvg.prototype.getHeightWidth = function() {
|
||||
return {height: height, width: width};
|
||||
};
|
||||
|
||||
/**
|
||||
* Position a new block correctly, so that it doesn't move the existing block
|
||||
* when connected to it.
|
||||
* @param {!Blockly.Block} newBlock The block to position - either the first
|
||||
* block in a dragged stack or an insertion marker.
|
||||
* @param {!Blockly.Connection} newConnection The connection on the new block's
|
||||
* stack - either a connection on newBlock, or the last NEXT_STATEMENT
|
||||
* connection on the stack if the stack's being dropped before another
|
||||
* block.
|
||||
* @param {!Blockly.Connection} existingConnection The connection on the
|
||||
* existing block, which newBlock should line up with.
|
||||
* @package
|
||||
*/
|
||||
Blockly.BlockSvg.prototype.positionNewBlock = function(newBlock, newConnection,
|
||||
existingConnection) {
|
||||
// We only need to position the new block if it's before the existing one,
|
||||
// otherwise its position is set by the previous block.
|
||||
if (newConnection.type == Blockly.NEXT_STATEMENT ||
|
||||
newConnection.type == Blockly.INPUT_VALUE) {
|
||||
var dx = existingConnection.x_ - newConnection.x_;
|
||||
var dy = existingConnection.y_ - newConnection.y_;
|
||||
|
||||
newBlock.moveBy(dx, dy);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Visual effect to show that if the dragging block is dropped, this block will
|
||||
* be replaced. If a shadow block, it will disappear. Otherwise it will bump.
|
||||
|
||||
@@ -668,8 +668,8 @@ Blockly.InsertionMarkerManager.prototype.connectMarker_ = function() {
|
||||
imBlock.rendered = true;
|
||||
imBlock.getSvgRoot().setAttribute('visibility', 'visible');
|
||||
|
||||
// Position based on the calculated connection locations.
|
||||
imBlock.positionNewBlock(imBlock, imConn, closest);
|
||||
// Position so that the existing block doesn't move.
|
||||
imBlock.positionNearConnection(imConn, closest);
|
||||
|
||||
// Connect() also renders the insertion marker.
|
||||
imConn.connect(closest);
|
||||
|
||||
Reference in New Issue
Block a user