diff --git a/components/canvas/DrawCanvas.tsx b/components/canvas/DrawCanvas.tsx index 5fe8f3e..e9011a3 100644 --- a/components/canvas/DrawCanvas.tsx +++ b/components/canvas/DrawCanvas.tsx @@ -235,15 +235,21 @@ const setupCanvasListeners = ( lastCoords.current = { x: event.offsetX, y: event.offsetY } } + const onMouseLeave = () => { + drawingRef.current = false; + } + canvas.addEventListener("mousedown", onMouseDown) canvas.addEventListener("mouseup", stopDrawing) canvas.addEventListener("mousemove", onMouseMove) + canvas.addEventListener("mouseleave", onMouseLeave) return () => { if (canvas) { canvas.removeEventListener("mousedown", onMouseDown) canvas.removeEventListener("mouseup", stopDrawing) canvas.removeEventListener("mousemove", onMouseMove) + canvas.removeEventListener("mouseleave", onMouseLeave) } } } diff --git a/package.json b/package.json index 5f7d974..50ff6b9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fake-artist", - "version": "1.0.0", + "version": "1.0.1", "private": true, "scripts": { "dev": "next dev",