Skip to content

Commit 77b136c

Browse files
committed
cursor updated
1 parent 0ed8551 commit 77b136c

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

src/components/DrawArea.tsx

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,29 @@ const DrawArea: FunctionComponent<IDrawArea> = ({
4949
const [isDrawMode, setIsDrawMode] = drawModeState;
5050
const [isDrawing, setIsDrawing] = React.useState(isDrawMode);
5151

52-
const handleContentClick = (e: any) => {
52+
const handleContentMousedown = (e: any) => {
5353
if (!isDrawMode) return;
54-
// if we are drawing a shape, a click finishes the drawing
55-
if (isDrawing) {
56-
setIsDrawing(!isDrawing);
57-
setIsDrawMode(false);
58-
return;
59-
}
6054

61-
// otherwise, add a new rectangle at the mouse position with 0 width and height,
6255
// and set isDrawing to true
6356
const newArea: IgnoreArea = {
6457
id: Date.now().toString(),
6558
x: e.evt.layerX / stageScale,
6659
y: e.evt.layerY / stageScale,
67-
width: 0,
68-
height: 0,
60+
width: MIN_RECT_SIDE_PIXEL,
61+
height: MIN_RECT_SIDE_PIXEL,
6962
};
7063
setIgnoreAreas([...ignoreAreas, newArea]);
7164
setSelectedRectId(newArea.id);
7265
setIsDrawing(true);
7366
};
7467

68+
const handleContentMouseup = (e: any) => {
69+
if (isDrawing) {
70+
setIsDrawing(!isDrawing);
71+
setIsDrawMode(false);
72+
}
73+
};
74+
7575
const handleContentMouseMove = (e: any) => {
7676
if (!isDrawMode) return;
7777

@@ -132,14 +132,15 @@ const DrawArea: FunctionComponent<IDrawArea> = ({
132132
transform: `scale(${stageScale})`,
133133
transformOrigin: "top left",
134134
}}
135-
onContentMousedown={handleContentClick}
135+
onContentMousedown={handleContentMousedown}
136+
onContentMouseup={handleContentMouseup}
136137
onContentMouseMove={handleContentMouseMove}
137138
>
138139
<Layer>
139140
<Image
140141
image={image}
141142
onMouseOver={(event) => {
142-
document.body.style.cursor = "grab";
143+
document.body.style.cursor = isDrawMode ? "crosshair" : "grab";
143144
}}
144145
onMouseDown={(event) => {
145146
document.body.style.cursor = "grabbing";

src/components/TestDetailsModal.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ const TestDetailsModal: React.FunctionComponent<{
343343
stagePosState={[stagePos, setStagePos]}
344344
stageInitPosState={[stageInitPos, setStageInitPos]}
345345
stageOffsetState={[stageOffset, setStageOffset]}
346-
drawModeState={[isDrawMode, setIsDrawMode]}
346+
drawModeState={[false, setIsDrawMode]}
347347
/>
348348
</div>
349349
</Grid>

0 commit comments

Comments
 (0)