From 83fc03b31351cd97e294383c527393834f72d8d9 Mon Sep 17 00:00:00 2001 From: freesemar93 <46578442-freesemar93@users.noreply.replit.com> Date: Mon, 18 Aug 2025 12:40:00 +0000 Subject: [PATCH] Improve canvas zooming and scrolling with mouse wheel for smoother interaction Implement mouse wheel zooming and smooth scrolling for the canvas component, enhance WebSocket connection management with automatic reconnection and keep-alive pings, and refine CSS for pixel hover effects. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 0385ea33-cde8-4bbd-8fce-8d192d30eb41 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/870d08ce-da3b-4822-9874-c2fe2b7628b1/0385ea33-cde8-4bbd-8fce-8d192d30eb41/PVrRiEe --- client/src/components/canvas.tsx | 22 ++++- client/src/hooks/use-websocket.tsx | 89 ++++++++++++++------- client/src/index.css | 37 ++++++--- exports/canvas-2025-08-18T12-34-32-373Z.svg | 1 + exports/canvas-2025-08-18T12-35-32-373Z.svg | 1 + exports/canvas-2025-08-18T12-36-32-373Z.svg | 1 + exports/canvas-2025-08-18T12-37-32-373Z.svg | 1 + server/routes.ts | 28 ++++++- 8 files changed, 135 insertions(+), 45 deletions(-) create mode 100644 exports/canvas-2025-08-18T12-34-32-373Z.svg create mode 100644 exports/canvas-2025-08-18T12-35-32-373Z.svg create mode 100644 exports/canvas-2025-08-18T12-36-32-373Z.svg create mode 100644 exports/canvas-2025-08-18T12-37-32-373Z.svg diff --git a/client/src/components/canvas.tsx b/client/src/components/canvas.tsx index 87c0b5b..8ec9277 100644 --- a/client/src/components/canvas.tsx +++ b/client/src/components/canvas.tsx @@ -57,6 +57,21 @@ export function Canvas({ setZoom(1); }; + const handleWheel = (e: React.WheelEvent) => { + e.preventDefault(); + + const zoomFactor = 1.1; + const delta = e.deltaY; + + if (delta < 0) { + // Rein zoomen + setZoom(prev => Math.min(prev * zoomFactor, 3)); + } else { + // Raus zoomen + setZoom(prev => Math.max(prev / zoomFactor, 0.5)); + } + }; + useEffect(() => { setPixelSize(Math.max(2, 8 * zoom)); }, [zoom]); @@ -71,11 +86,12 @@ export function Canvas({