blockly > Block > moveBy
Block.moveBy() method
Move a block by a relative offset.
Signature:
moveBy(dx: number, dy: number, reason?: string[]): void;
Parameters
Parameter |
Type |
Description |
dx |
number |
Horizontal offset, in workspace units. |
dy |
number |
Vertical offset, in workspace units. |
reason |
string[] |
(Optional) Why is this move happening? 'drag', 'bump', 'snap', ... |
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.
[null,null,["Last updated 2024-09-18 UTC."],[[["The `moveBy()` method moves a block by a specified horizontal (dx) and vertical (dy) offset within the workspace."],["This movement can be attributed to various reasons like dragging, bumping, or snapping, indicated by an optional 'reason' parameter."],["The function does not return any value (void)."]]],["The `Block.moveBy()` method allows for the relocation of a block within a workspace using relative offsets. It takes two mandatory numerical parameters, `dx` and `dy`, representing the horizontal and vertical offsets respectively, in workspace units. An optional string array parameter, `reason`, explains the cause of the movement, such as 'drag' or 'snap'. The method does not return any value.\n"]]