@@ -1515,38 +1515,13 @@ export class BlockSvg
15151515 * or an insertion marker.
15161516 *
15171517 * @param sourceConnection The connection on the moving block's stack.
1518- * @param targetConnection The connection that should stay stationary as this
1519- * block is positioned.
1518+ * @param originalOffsetToTarget The connection original offset to the target connection
1519+ * @param originalOffsetInBlock The connection original offset in its block
15201520 * @internal
15211521 */
15221522 positionNearConnection (
15231523 sourceConnection : RenderedConnection ,
1524- targetConnection : RenderedConnection ,
1525- ) {
1526- // We only need to position the new block if it's before the existing one,
1527- // otherwise its position is set by the previous block.
1528- if (
1529- sourceConnection . type === ConnectionType . NEXT_STATEMENT ||
1530- sourceConnection . type === ConnectionType . INPUT_VALUE
1531- ) {
1532- const dx = targetConnection . x - sourceConnection . x ;
1533- const dy = targetConnection . y - sourceConnection . y ;
1534-
1535- this . moveBy ( dx , dy ) ;
1536- }
1537- }
1538-
1539- /**
1540- * Reposition a block after its connection has been resized, to match exactly the target block position.
1541- * The block to position is usually either the first block in a dragged stack
1542- * or an insertion marker.
1543- *
1544- * @param sourceConnection The connection on the moving block's stack.
1545- * @param originalOffsetInBlock The connection original offset in its block, before the resize occured
1546- * @internal
1547- */
1548- repositionAfterConnectionResize (
1549- sourceConnection : RenderedConnection ,
1524+ originalOffsetToTarget : { x : number ; y : number } ,
15501525 originalOffsetInBlock : Coordinate ,
15511526 ) {
15521527 // We only need to position the new block if it's before the existing one,
@@ -1555,8 +1530,12 @@ export class BlockSvg
15551530 sourceConnection . type === ConnectionType . NEXT_STATEMENT ||
15561531 sourceConnection . type === ConnectionType . INPUT_VALUE
15571532 ) {
1558- const dx = originalOffsetInBlock . x - sourceConnection . getOffsetInBlock ( ) . x ;
1559- const dy = originalOffsetInBlock . y - sourceConnection . getOffsetInBlock ( ) . y ;
1533+ // First move the block to match the orginal target connection position
1534+ let dx = originalOffsetToTarget . x ;
1535+ let dy = originalOffsetToTarget . y ;
1536+ // Then adjust its position according to the connection resize
1537+ dx += originalOffsetInBlock . x - sourceConnection . getOffsetInBlock ( ) . x ;
1538+ dy += originalOffsetInBlock . y - sourceConnection . getOffsetInBlock ( ) . y ;
15601539
15611540 this . moveBy ( dx , dy ) ;
15621541 }
0 commit comments