Stay organized with collections
Save and categorize content based on your preferences.
blockly > blockRendering > RenderInfo > getElemCenterline_
blockRendering.RenderInfo.getElemCenterline_() method
Calculate the centerline of an element in a rendered row. This base implementation puts the centerline at the middle of the row vertically, with no special cases. You will likely need extra logic to handle (at minimum) top and bottom rows.
Signature:
protected getElemCenterline_(row: Row, elem: Measurable): number;
Parameters
Parameter |
Type |
Description |
row |
Row |
The row containing the element. |
elem |
Measurable |
The element to place. |
Returns:
number
The desired centerline of the given element, as an offset from the top left of the block.
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\u003eThe \u003ccode\u003egetElemCenterline_\u003c/code\u003e method calculates the vertical center of an element within a rendered row of a block.\u003c/p\u003e\n"],["\u003cp\u003eIt positions elements in the middle of the row by default, but additional logic may be needed for top and bottom rows.\u003c/p\u003e\n"],["\u003cp\u003eThis method is primarily used within the block rendering process to determine element placement.\u003c/p\u003e\n"],["\u003cp\u003eIt takes the row and the element as input and returns the vertical offset from the block's top left corner.\u003c/p\u003e\n"]]],["The `getElemCenterline_()` method calculates the vertical centerline of an element within a rendered row. It positions the centerline at the row's vertical midpoint. The method takes a `Row` and a `Measurable` element as input. It returns a number representing the element's centerline offset from the block's top-left corner. Custom implementations are often needed to adjust positioning for specific rows.\n"],null,["[blockly](./blockly.md) \\\u003e [blockRendering](./blockly.blockrendering_namespace.md) \\\u003e [RenderInfo](./blockly.blockrendering_namespace.renderinfo_class.md) \\\u003e [getElemCenterline_](./blockly.blockrendering_namespace.renderinfo_class.getelemcenterline__1_method.md)\n\nblockRendering.RenderInfo.getElemCenterline_() method\n-----------------------------------------------------\n\nCalculate the centerline of an element in a rendered row. This base implementation puts the centerline at the middle of the row vertically, with no special cases. You will likely need extra logic to handle (at minimum) top and bottom rows.\n\n**Signature:** \n\n protected getElemCenterline_(row: Row, elem: Measurable): number;\n\nParameters\n----------\n\n| Parameter | Type | Description |\n|-----------|----------------------------------------------------------------------|---------------------------------|\n| row | [Row](./blockly.blockrendering_namespace.row_class.md) | The row containing the element. |\n| elem | [Measurable](./blockly.blockrendering_namespace.measurable_class.md) | The element to place. |\n\n**Returns:**\n\nnumber\n\nThe desired centerline of the given element, as an offset from the top left of the block."]]