Stay organized with collections
Save and categorize content based on your preferences.
blockly > WorkspaceSvg > centerOnBlock
WorkspaceSvg.centerOnBlock() method
Scroll the workspace to center on the given block. If the block has other blocks stacked below it, the workspace will be centered on the stack, unless blockOnly is true.
Signature:
centerOnBlock(id: string | null, blockOnly?: boolean): void;
Parameters
Parameter |
Type |
Description |
id |
string | null |
ID of block center on. |
blockOnly |
boolean |
(Optional) True to center only on the block itself, not its stack. |
Returns:
void
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["\u003cp\u003eThis method centers the workspace view on a specific block, identified by its ID.\u003c/p\u003e\n"],["\u003cp\u003eIt optionally allows centering solely on the block, disregarding any connected blocks below it.\u003c/p\u003e\n"],["\u003cp\u003eThe method belongs to the \u003ccode\u003eWorkspaceSvg\u003c/code\u003e class and is used for manipulating the visual display of the workspace.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [WorkspaceSvg](./blockly.workspacesvg_class.md) \\\u003e [centerOnBlock](./blockly.workspacesvg_class.centeronblock_1_method.md)\n\nWorkspaceSvg.centerOnBlock() method\n\nScroll the workspace to center on the given block. If the block has other blocks stacked below it, the workspace will be centered on the stack, unless blockOnly is true.\n\n**Signature:** \n\n centerOnBlock(id: string | null, blockOnly?: boolean): void;\n\nParameters\n\n| Parameter | Type | Description |\n|-----------|----------------|----------------------------------------------------------------------|\n| id | string \\| null | ID of block center on. |\n| blockOnly | boolean | *(Optional)* True to center only on the block itself, not its stack. |\n\n**Returns:**\n\nvoid"]]