diff --git a/frontend/src/GraphView.jsx b/frontend/src/GraphView.jsx index 3416a5e..18a765f 100644 --- a/frontend/src/GraphView.jsx +++ b/frontend/src/GraphView.jsx @@ -88,6 +88,15 @@ function GraphView({ servers, connections }) { }); svg.call(zoomRef.current); dbg('zoom initialized', { width, height }); + + // Колёсико мыши — обычный масштаб (желательно для UX) + svg.on('wheel.zoom', null); // убираем двойное навешивание + svg.on('wheel', (event) => { + event.preventDefault(); + const delta = Math.sign(event.deltaY); + const factor = delta > 0 ? 1 / 1.2 : 1.2; + zoomBy(factor); + }, { passive: false }); }, []); // Контролы масштабирования @@ -153,6 +162,19 @@ function GraphView({ servers, connections }) { } }; + const resetZoom = () => { + if (!zoomRef.current || !svgRef.current) return; + const svgEl = svgRef.current; + d3.select(svgEl) + .transition() + .duration(220) + .call(zoomRef.current.transform, d3.zoomIdentity) + .on('end', () => { + const nt = d3.zoomTransform(svgEl); + dbg('resetZoom end', { k: nt.k, x: nt.x, y: nt.y }); + }); + }; + if (servers.length === 0) { return (