From 63fce9a40c3e3265db102164ae987cdad803ba58 Mon Sep 17 00:00:00 2001 From: Mark Tolmacs Date: Fri, 26 Jun 2026 08:23:49 +0000 Subject: [PATCH] fix: Remove dead code Signed-off-by: Mark Tolmacs --- packages/excalidraw/scroll.ts | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/packages/excalidraw/scroll.ts b/packages/excalidraw/scroll.ts index d35ee161bb..17848d7710 100644 --- a/packages/excalidraw/scroll.ts +++ b/packages/excalidraw/scroll.ts @@ -214,8 +214,6 @@ const getTargetViewport = ( targetElements: readonly ExcalidrawElement[], opts?: ScrollToContentOptions, ): Viewport => { - let viewport: Viewport; - if (opts?.fitToContent || opts?.fitToViewport) { const { appState } = zoomToFit({ canvasOffsets: opts.canvasOffsets, @@ -227,19 +225,16 @@ const getTargetViewport = ( maxZoom: opts.maxZoom, }); - viewport = { + return { scrollX: appState.scrollX, scrollY: appState.scrollY, zoom: appState.zoom, }; - } else { - // keep the current zoom, only recenter the viewport on the target - const { scrollX, scrollY } = calculateScrollCenter(targetElements, state); - viewport = { scrollX, scrollY, zoom: state.zoom }; } + // keep the current zoom, only recenter the viewport on the target + const { scrollX, scrollY } = calculateScrollCenter(targetElements, state); - // keep programmatic scrolling within the constraint box, if any - return constrainScrollState({ ...state, ...viewport }); + return { scrollX, scrollY, zoom: state.zoom }; }; /** @@ -310,9 +305,6 @@ const animateToViewport = ( shouldCacheIgnoreZoom: progress < 1, // ignore zoom caching while animating }); - // returning a falsy value signals the AnimationController to remove the - // animation; otherwise it would keep ticking (and calling onFrame) every - // frame forever after reaching the target return progress < 1 ? { elapsed } : null; }, );