Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/workspace_utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,15 @@ import * as Blockly from 'blockly/core';
* @param workspace The workspace to scroll the given bounds into view in.
*/
export function scrollBoundsIntoView(
originalBounds: Blockly.utils.Rect,
bounds: Blockly.utils.Rect,
workspace: Blockly.WorkspaceSvg,
) {
if (Blockly.Gesture.inProgress()) {
// This can cause jumps during a drag and it only suited for keyboard nav.
return;
}
const scale = workspace.getScale();

const bounds = originalBounds.clone();

// Add some padding to the bounds so the element is scrolled comfortably
// into view.
bounds.top -= 10;
bounds.bottom += 10;
bounds.left -= 10;
bounds.right += 10;

const rawViewport = workspace.getMetricsManager().getViewMetrics(true);
const viewport = new Blockly.utils.Rect(
rawViewport.top,
Expand All @@ -49,6 +44,14 @@ export function scrollBoundsIntoView(
return;
}

// Add some padding to the bounds so the element is scrolled comfortably
// into view.
bounds = bounds.clone();
bounds.top -= 10;
bounds.bottom += 10;
bounds.left -= 10;
bounds.right += 10;

let deltaX = 0;
let deltaY = 0;

Expand Down