From c6b0ada2c3d42e5e0adec9abfc864a0a71b6e78a Mon Sep 17 00:00:00 2001 From: "b.kotov" Date: Wed, 11 Mar 2026 13:02:35 +0300 Subject: [PATCH] feat: Add support for going to the beginning of a block --- packages/blockly/core/workspace_svg.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) 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;