mirror of
https://github.com/google/blockly.git
synced 2026-01-07 00:50:27 +01:00
feat: Add margin around zoomToFit (#6042)
* Add margin around zoomToFit * Change configurable property to fixed constant. * VS Code keeps indenting stuff for no reason.
This commit is contained in:
@@ -116,6 +116,12 @@ goog.require('Blockly.MetricsManager');
|
||||
goog.require('Blockly.Msg');
|
||||
|
||||
|
||||
/**
|
||||
* Margin around the top/bottom/left/right after a zoomToFit call.
|
||||
* @const
|
||||
*/
|
||||
const ZOOM_TO_FIT_MARGIN = 20;
|
||||
|
||||
/**
|
||||
* Class for a workspace. This is an onscreen area with optional trashcan,
|
||||
* scrollbars, bubbles, and dragging.
|
||||
@@ -2168,8 +2174,9 @@ class WorkspaceSvg extends Workspace {
|
||||
let workspaceWidth = metrics.viewWidth;
|
||||
let workspaceHeight = metrics.viewHeight;
|
||||
const blocksBox = this.getBlocksBoundingBox();
|
||||
let blocksWidth = blocksBox.right - blocksBox.left;
|
||||
let blocksHeight = blocksBox.bottom - blocksBox.top;
|
||||
const doubleMargin = ZOOM_TO_FIT_MARGIN * 2;
|
||||
let blocksWidth = blocksBox.right - blocksBox.left + doubleMargin;
|
||||
let blocksHeight = blocksBox.bottom - blocksBox.top + doubleMargin;
|
||||
if (!blocksWidth) {
|
||||
return; // Prevents zooming to infinity.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user