diff --git a/packages/blockly/core/workspace_svg.ts b/packages/blockly/core/workspace_svg.ts index c693225970f..59a1402b932 100644 --- a/packages/blockly/core/workspace_svg.ts +++ b/packages/blockly/core/workspace_svg.ts @@ -1987,8 +1987,9 @@ export class WorkspaceSvg * * @param id ID of block center on. * @param blockOnly True to center only on the block itself, not its stack. + * @param centerOnBlockStart It is correct to center only on the block itself at its beginning. */ - centerOnBlock(id: string | null, blockOnly?: boolean) { + centerOnBlock(id: string | null, blockOnly?: boolean, centerOnBlockStart?: boolean) { if (!this.isMovable()) { console.warn( 'Tried to move a non-movable workspace. This could result' + @@ -2010,7 +2011,9 @@ export class WorkspaceSvg : block.getHeightWidth(); // Find the enter of the block in workspace units. - const blockCenterY = xy.y + heightWidth.height / 2; + const blockCenterY = centerOnBlockStart + ? xy.y + : xy.y + heightWidth.height / 2; // In RTL the block's position is the top right of the block, not top left. const multiplier = this.RTL ? -1 : 1;