This commit is contained in:
backuppc
2025-12-23 13:17:16 +09:00
parent 4d1f131d3e
commit 97e028f3a1
4 changed files with 873 additions and 1018 deletions

View File

@@ -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}