Stay organized with collections
Save and categorize content based on your preferences.
blockly > IMetricsManager > getMetrics
IMetricsManager.getMetrics() method
Returns an object with all the metrics required to size scrollbars for a top level workspace. The following properties are computed: Coordinate system: pixel coordinates, -left, -up, +right, +down .viewHeight: Height of the visible portion of the workspace. .viewWidth: Width of the visible portion of the workspace. .contentHeight: Height of the content. .contentWidth: Width of the content. .svgHeight: Height of the Blockly div (the view + the toolbox, simple or otherwise), .svgWidth: Width of the Blockly div (the view + the toolbox, simple or otherwise), .viewTop: Top-edge of the visible portion of the workspace, relative to the workspace origin. .viewLeft: Left-edge of the visible portion of the workspace, relative to the workspace origin. .contentTop: Top-edge of the content, relative to the workspace origin. .contentLeft: Left-edge of the content relative to the workspace origin. .absoluteTop: Top-edge of the visible portion of the workspace, relative to the blocklyDiv. .absoluteLeft: Left-edge of the visible portion of the workspace, relative to the blocklyDiv. .toolboxWidth: Width of the toolbox, if it exists. Otherwise zero. .toolboxHeight: Height of the toolbox, if it exists. Otherwise zero. .flyoutWidth: Width of the flyout if it is always open. Otherwise zero. .flyoutHeight: Height of the flyout if it is always open. Otherwise zero. .toolboxPosition: Top, bottom, left or right. Use TOOLBOX_AT constants to compare.
Signature:
getMetrics(): Metrics;
Returns:
Metrics
Contains size and position metrics of a top level workspace.
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."],[[["`IMetricsManager.getMetrics()` provides essential measurements for sizing scrollbars in a Blockly workspace."],["The returned `Metrics` object includes properties like view dimensions, content dimensions, toolbox dimensions, and flyout dimensions in pixels."],["All coordinates are calculated using a pixel-based system with the origin at the top-left, increasing downwards and rightwards."],["These metrics consider the workspace, toolbox, and flyout, offering comprehensive data for scrollbar calculations."],["The method helps in dynamically adjusting scrollbars based on the workspace's content and layout."]]],["The `getMetrics()` method, part of the `IMetricsManager` interface, returns a `Metrics` object detailing the size and position of a top-level Blockly workspace. This includes properties such as `viewHeight`, `viewWidth`, `contentHeight`, `contentWidth`, `svgHeight`, and `svgWidth`. It also includes `viewTop`, `viewLeft`, `contentTop`, `contentLeft`, `absoluteTop`, `absoluteLeft`. It calculates the size and location of the toolbox (`toolboxWidth`, `toolboxHeight`) and the flyout (`flyoutWidth`, `flyoutHeight`), and returns the `toolboxPosition` as top, bottom, left or right.\n"]]