diff --git a/modules/canvas/components/Minimap.tsx b/modules/canvas/components/Minimap.tsx index af5ced3..4c67675 100644 --- a/modules/canvas/components/Minimap.tsx +++ b/modules/canvas/components/Minimap.tsx @@ -50,6 +50,7 @@ return ( dragConstraints={containerRef} dragElastic={0} dragTransition= {{power:0, timeConstant:0}} + onDragStart={()=> setMovedMiniMap((prev)=>!prev)} onDragEnd={()=> setMovedMiniMap((prev:boolean)=> !prev)} className="absolute top-0 left-0 cursor-grab border-2 border-red-500" style={{ @@ -60,8 +61,7 @@ return ( }} animate={{x: x.get() / -10, y: y.get() / -10}} transition={{duration: 0.1}} - > - + > ) }); diff --git a/modules/canvas/hooks/Canvas.hooks.ts b/modules/canvas/hooks/Canvas.hooks.ts index 25385fa..0b85a24 100644 --- a/modules/canvas/hooks/Canvas.hooks.ts +++ b/modules/canvas/hooks/Canvas.hooks.ts @@ -34,20 +34,21 @@ ctx.lineTo(x+movedX,y+movedY); ctx.stroke(); }; const handleEndDrawing = () =>{ -if(!ctx) return ; +if(!ctx || blocked) return ; socket.emit("draw", moves, options); setDrawing(false); ctx.closePath(); handleEnd(); }; const handleDraw= (x:number, y:number) =>{ - if(ctx && drawing && !blocked){ - moves.push([x+movedX,y+movedY]); - ctx.lineTo(x,y); - ctx.stroke(); + if(!ctx || !drawing || blocked){ + return; } + moves.push([x+movedX,y+movedY]); + ctx.lineTo(x,y); + ctx.stroke(); -} +}; return { handleEndDrawing,