Stay organized with collections
Save and categorize content based on your preferences.
blockly > MetricsManager > getViewMetrics
MetricsManager.getViewMetrics() method
Gets the metrics for the visible workspace in either pixel or workspace coordinates. The visible workspace does not include the toolbox or flyout.
Signature:
getViewMetrics(opt_getWorkspaceCoordinates?: boolean): ContainerRegion;
Parameters
Parameter |
Type |
Description |
opt_getWorkspaceCoordinates |
boolean |
(Optional) True to get the view metrics in workspace coordinates, false to get them in pixel coordinates. |
Returns:
ContainerRegion
The width, height, top and left of the viewport in either workspace coordinates or pixel coordinates.
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."],[[["`MetricsManager.getViewMetrics()` provides the dimensions and position of the visible workspace area."],["The method can return metrics in either pixel or workspace coordinates, depending on the `opt_getWorkspaceCoordinates` parameter."],["Metrics exclude the toolbox and flyout, focusing solely on the main workspace area."]]],["The `getViewMetrics()` method in `MetricsManager` retrieves metrics for the visible workspace, excluding the toolbox and flyout. It accepts an optional boolean parameter, `opt_getWorkspaceCoordinates`, to specify whether to return metrics in workspace coordinates (true) or pixel coordinates (false). The method returns a `ContainerRegion` object, containing the viewport's width, height, top, and left values.\n"]]