feat: Add support for going to the beginning of a block#9629
feat: Add support for going to the beginning of a block#9629bbrudastyy wants to merge 4 commits intoRaspberryPiFoundation:mainfrom
Conversation
There was a problem hiding this comment.
Welcome! It looks like this is your first pull request in Blockly, so here are a couple of tips:
- You can find tips about contributing to Blockly and how to validate your changes on our developer site.
- We use conventional commits to make versioning the package easier. Make sure your commit message is in the proper format or learn how to fix it.
- If any of the other checks on this PR fail, you can click on them to learn why. It might be that your change caused a test failure, or that you need to double-check the style guide.
Thank you for opening this PR! A member of the Blockly team will review it soon.
There was a problem hiding this comment.
Thanks for the PR! This seems very useful, but I think it would be better if this was automatic rather than requiring the caller to request this behavior. Would you be open to revising this change to always center on the top of the block if the block being centered is taller than the current viewport? It would be good to have a test or two as well.
Hi, you want to center the block to the beginning at the xy coordinates.y only if the procedure definition does not fit in the workspace viewport? If it fits, then leave xy.y + heightWidth.height / 2? |
|
Yes, if the block fits within the viewport it should be centered (current Blockly behavior), but if it's too tall to fit completely in view then the top of the block should be centered vertically in the workspace (like you change does). Thanks! |
|
I have placed the block definition in the block_svg file. In the future, you may need to #9640 |
The basics
The details
Resolves
Fixes #9628
Proposed Changes
Allows you to center a block at its beginning.
Reason for Changes
Centering takes place in the center of the block, which is inconvenient, for example, when switching to defining a procedure.

You can use the changes to go to the beginning.

Test Coverage
The changes do not affect existing tests and do not require writing new ones.
Documentation
JSDoc has been updated
https://developers.google.com/blockly/reference/js/blockly.workspacesvg_class.centeronblock_1_method?hl=it
Additional Information
No