Stay organized with collections
Save and categorize content based on your preferences.
blockly > Events > ViewportChange
Events.ViewportChange class
Notifies listeners that the workspace surface's position or scale has changed.
Does not notify when the workspace itself resizes.
Signature:
export declare class ViewportChange extends UiBase
Extends: UiBase
Constructors
Properties
Property |
Modifiers |
Type |
Description |
oldScale? |
|
number |
(Optional) The previous scale of the workspace. |
scale? |
|
number |
(Optional) The scale of the workpace. |
type |
|
EventType |
|
viewLeft? |
|
number |
(Optional) The left edge of the visible portion of the workspace, relative to the workspace origin. |
viewTop? |
|
number |
(Optional) Top edge of the visible portion of the workspace, relative to the workspace origin. |
Methods
Method |
Modifiers |
Description |
toJson() |
|
Encode the event as JSON. |
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 2025-05-16 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 2025-05-16 UTC."],[[["The `ViewportChange` event is triggered when the workspace view changes, such as panning or zooming."],["This event provides information about the new and previous scale and position of the workspace view."],["It does not trigger when the workspace itself resizes, only when the visible area changes."],["Developers can use this event to react to workspace view changes and update UI elements accordingly."]]],["The `ViewportChange` class notifies listeners about changes to the workspace surface's position or scale, excluding workspace resizing. It extends the `UiBase` class. Key properties include `oldScale`, `scale`, `viewLeft`, and `viewTop`, representing the previous and current scale, and the visible portion's edges, respectively. The class's constructor creates new instances, and the `toJson()` method encodes the event into JSON format. Its purpose is to inform of changes in what the user see.\n"]]