From 6e331d430b9e4cfb5bf50e038acb7ae6452970ea Mon Sep 17 00:00:00 2001 From: Erik Pasternak Date: Wed, 23 Apr 2025 09:46:25 -0700 Subject: [PATCH] Fix: Add padding to the bounds before deciding if it should scroll This makes it easier to scroll something into view with context by including the padding before checking if it should be scrolled into view. --- core/workspace_svg.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/core/workspace_svg.ts b/core/workspace_svg.ts index 91668b744d4..3f58c9aef48 100644 --- a/core/workspace_svg.ts +++ b/core/workspace_svg.ts @@ -2581,24 +2581,24 @@ export class WorkspaceSvg rawViewport.left + rawViewport.width, ); + // Add the padding to the bounds so the element is scrolled comfortably + // into view. + bounds = bounds.clone(); + bounds.top -= padding; + bounds.bottom += padding; + bounds.left -= padding; + bounds.right += padding; + if ( bounds.left >= viewport.left && bounds.top >= viewport.top && bounds.right <= viewport.right && bounds.bottom <= viewport.bottom ) { - // Do nothing if the block is fully inside the viewport. + // Do nothing if the block with padding is fully inside the viewport. return; } - // Add some padding to the bounds so the element is scrolled comfortably - // into view. - bounds = bounds.clone(); - bounds.top -= padding; - bounds.bottom += padding; - bounds.left -= padding; - bounds.right += padding; - let deltaX = 0; let deltaY = 0;