...
This commit is contained in:
@@ -1211,7 +1211,7 @@ const SimulationCanvas: React.FC<SimulationCanvasProps> = ({ activeTool, mapData
|
||||
return { x: rawX, y: rawY };
|
||||
};
|
||||
|
||||
const handleWheel = (e: React.WheelEvent) => {
|
||||
const handleWheel = useCallback((e: WheelEvent) => {
|
||||
e.preventDefault();
|
||||
const rect = canvasRef.current?.getBoundingClientRect();
|
||||
if (!rect) return;
|
||||
@@ -1234,7 +1234,20 @@ const SimulationCanvas: React.FC<SimulationCanvasProps> = ({ activeTool, mapData
|
||||
const newY = screenY - worldY * newScale;
|
||||
|
||||
viewRef.current = { x: newX, y: newY, scale: newScale };
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Attach non-passive wheel listener
|
||||
useEffect(() => {
|
||||
const canvas = canvasRef.current;
|
||||
if (canvas) {
|
||||
canvas.addEventListener('wheel', handleWheel, { passive: false });
|
||||
}
|
||||
return () => {
|
||||
if (canvas) {
|
||||
canvas.removeEventListener('wheel', handleWheel);
|
||||
}
|
||||
};
|
||||
}, [handleWheel]);
|
||||
|
||||
const handleMouseMove = (e: React.MouseEvent) => {
|
||||
const rect = canvasRef.current?.getBoundingClientRect();
|
||||
@@ -1547,7 +1560,7 @@ const SimulationCanvas: React.FC<SimulationCanvasProps> = ({ activeTool, mapData
|
||||
setSelectedItemIds(newSelection);
|
||||
|
||||
// Prepare Multi-Drag
|
||||
const initialStates: Record<string, any> = {};
|
||||
const initialStates: any = {};
|
||||
newSelection.forEach(id => {
|
||||
const n = mapData.nodes.find(o => o.id === id);
|
||||
if (n) initialStates[id] = { x: n.x, y: n.y };
|
||||
@@ -1648,7 +1661,6 @@ const SimulationCanvas: React.FC<SimulationCanvasProps> = ({ activeTool, mapData
|
||||
ref={canvasRef}
|
||||
width={dimensions.width}
|
||||
height={dimensions.height}
|
||||
onWheel={handleWheel}
|
||||
onMouseDown={handleMouseDown}
|
||||
onMouseMove={handleMouseMove}
|
||||
onMouseUp={handleMouseUp}
|
||||
|
||||
Reference in New Issue
Block a user