From c00ee908e4a01b204f1881fb7ff39e3513454511 Mon Sep 17 00:00:00 2001 From: Beka Westberg Date: Mon, 21 Oct 2019 18:51:04 -0700 Subject: [PATCH] Removed positionNewBlock (#3300) * Removed positionNewBlock --- core/block_svg.js | 35 +++++--------------------------- core/insertion_marker_manager.js | 4 ++-- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/core/block_svg.js b/core/block_svg.js index 9d18f68ed..850657ea6 100644 --- a/core/block_svg.js +++ b/core/block_svg.js @@ -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. diff --git a/core/insertion_marker_manager.js b/core/insertion_marker_manager.js index 3e9c234f0..1159ad4a8 100644 --- a/core/insertion_marker_manager.js +++ b/core/insertion_marker_manager.js @@ -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);