Skip to content

Commit

Permalink
add blocked condn checks
Browse files Browse the repository at this point in the history
  • Loading branch information
deveshidwivedi committed Jun 20, 2024
1 parent 6591fa0 commit 2cfe0d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions modules/canvas/components/Minimap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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={{
Expand All @@ -60,8 +61,7 @@ return (
}}
animate={{x: x.get() / -10, y: y.get() / -10}}
transition={{duration: 0.1}}
>
</motion.div>
></motion.div>
</div>
)
});
Expand Down
13 changes: 7 additions & 6 deletions modules/canvas/hooks/Canvas.hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2cfe0d0

Please sign in to comment.