From f5f71085b2ed92de076cab28e608db7cae4fa195 Mon Sep 17 00:00:00 2001 From: Denis Shatskiy Date: Fri, 8 Aug 2025 17:15:38 +0700 Subject: [PATCH] fix: Update zoom functionality in GraphView to use scaleBy instead of scaleTo for smoother zoom transitions and improved user experience --- frontend/src/GraphView.jsx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/frontend/src/GraphView.jsx b/frontend/src/GraphView.jsx index 5e35c6e..3416a5e 100644 --- a/frontend/src/GraphView.jsx +++ b/frontend/src/GraphView.jsx @@ -94,21 +94,16 @@ function GraphView({ servers, connections }) { const zoomBy = (factor) => { if (!zoomRef.current || !svgRef.current) return; const svgEl = svgRef.current; - const current = d3.zoomTransform(svgEl); const cx = svgEl.clientWidth / 2; const cy = svgEl.clientHeight / 2; - const minK = 0.3; - const maxK = 3; - let nextK = current.k * factor; - if (nextK < minK) nextK = minK; - if (nextK > maxK) nextK = maxK; - dbg('zoomBy click', { factor, current: { k: current.k, x: current.x, y: current.y }, nextK, center: { cx, cy } }); + const current = d3.zoomTransform(svgEl); + dbg('zoomBy click', { factor, current: { k: current.k, x: current.x, y: current.y }, center: { cx, cy } }); const svgSel = d3.select(svgEl); svgSel.interrupt(); svgSel .transition() .duration(220) - .call(zoomRef.current.scaleTo, nextK, [cx, cy]) + .call(zoomRef.current.scaleBy, factor, [cx, cy]) .on('end', () => { const nt = d3.zoomTransform(svgEl); dbg('zoomBy end', { next: { k: nt.k, x: nt.x, y: nt.y } });