diff --git a/src/workspace_utilities.ts b/src/workspace_utilities.ts index 4e1fd298..f8616bea 100644 --- a/src/workspace_utilities.ts +++ b/src/workspace_utilities.ts @@ -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, @@ -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;