Skip to content

Commit 7204e16

Browse files
committed
stage offset fixed
1 parent 77b136c commit 7204e16

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/components/DrawArea.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,10 @@ const DrawArea: FunctionComponent<IDrawArea> = ({
5252
const handleContentMousedown = (e: any) => {
5353
if (!isDrawMode) return;
5454

55-
// and set isDrawing to true
5655
const newArea: IgnoreArea = {
5756
id: Date.now().toString(),
58-
x: e.evt.layerX / stageScale,
59-
y: e.evt.layerY / stageScale,
57+
x: (e.evt.layerX - stageOffset.x) / stageScale,
58+
y: (e.evt.layerY - stageOffset.y) / stageScale,
6059
width: MIN_RECT_SIDE_PIXEL,
6160
height: MIN_RECT_SIDE_PIXEL,
6261
};
@@ -77,8 +76,8 @@ const DrawArea: FunctionComponent<IDrawArea> = ({
7776

7877
if (isDrawing) {
7978
// update the current rectangle's width and height based on the mouse position + stage scale
80-
const mouseX = e.evt.layerX / stageScale;
81-
const mouseY = e.evt.layerY / stageScale;
79+
const mouseX = (e.evt.layerX - stageOffset.x) / stageScale;
80+
const mouseY = (e.evt.layerY - stageOffset.y) / stageScale;
8281

8382
const newShapesList = ignoreAreas.map((i) => {
8483
if (i.id === selectedRectId) {

src/components/TestDetailsModal.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ const TestDetailsModal: React.FunctionComponent<{
218218
</Grid>
219219
<Grid item>
220220
<ToggleButton
221+
value={"drawMode"}
221222
selected={isDrawMode}
222223
onClick={() => {
223224
setIsDrawMode(!isDrawMode);

0 commit comments

Comments
 (0)