Skip to content

Commit

Permalink
chore: Refactor. #1597
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Sep 27, 2022
1 parent aa11368 commit 313f5e2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
1 change: 0 additions & 1 deletion ui/src/image_annotator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ export const XImageAnnotator = ({ model }: { model: ImageAnnotator }) => {

switch (activeShape) {
case 'rect': {
// TODO: Fix rect selection.
rectRef.current?.onClick(e, cursor_x, cursor_y, setDrawnShapes, activeTag, start)
break
}
Expand Down
5 changes: 1 addition & 4 deletions ui/src/image_annotator_rect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@ export class RectAnnotator {
}

onClick = (e: React.MouseEvent, cursor_x: U, cursor_y: U, setDrawnShapes: (value: React.SetStateAction<DrawnShape[]>) => void, tag: S, start?: Position) => {
let newRect = null
if (start && !this.resizedCorner) {
const rect = this.createRect(start.x, cursor_x, start.y, cursor_y)
if (rect) newRect = ({ shape: { rect: rect }, tag })
if (rect) setDrawnShapes(drawnShapes => [{ shape: { rect }, tag }, ...drawnShapes])
}

if (!this.resizedCorner && !start?.dragging && e.type !== 'mouseleave') {
Expand All @@ -68,8 +67,6 @@ export class RectAnnotator {

this.resizedCorner = undefined
this.movedRect = undefined

return newRect
}

onMouseDown(cursor_x: U, cursor_y: U, rect: ImageAnnotatorRect) {
Expand Down

0 comments on commit 313f5e2

Please sign in to comment.