Skip to content

Commit

Permalink
chore: Minor refactor. #1597
Browse files Browse the repository at this point in the history
  • Loading branch information
mturoci committed Nov 3, 2022
1 parent a05b6e5 commit 5559986
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ui/src/image_annotator.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ describe('ImageAnnotator.tsx', () => {
])
})

it.only('Moves polygon by a single point, then moves it whole', async () => {
it('Moves polygon by a single point, then moves it whole', async () => {
const { container } = render(<XImageAnnotator model={model} />)
await waitForImgLoad()
const canvasEl = container.querySelectorAll('canvas')[1]
Expand Down
2 changes: 1 addition & 1 deletion ui/src/image_annotator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export const XImageAnnotator = ({ model }: { model: ImageAnnotator }) => {
canvas.parentElement!.style.height = px(height)

rectRef.current = new RectAnnotator(canvas)
polygonRef.current = new PolygonAnnotator(canvas)
if (ctxRef.current) polygonRef.current = new PolygonAnnotator(ctxRef.current)

ctx.drawImage(img, 0, 0, img.width, img.height, 0, 0, img.width * aspectRatio, img.height * aspectRatio)
if (!drawnShapes.length) {
Expand Down
3 changes: 1 addition & 2 deletions ui/src/image_annotator_polygon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import { DrawnPoint, DrawnShape, ImageAnnotatorPoint, Position } from "./image_a
import { ARC_RADIUS } from "./image_annotator_rect"

export class PolygonAnnotator {
private ctx: CanvasRenderingContext2D | null
private currPolygonPoints: ImageAnnotatorPoint[] = []
private draggedPoint: ImageAnnotatorPoint | null = null
private draggedShape: DrawnShape | null = null

constructor(private canvas: HTMLCanvasElement) { this.ctx = canvas.getContext('2d') }
constructor(private ctx: CanvasRenderingContext2D) { }

resetDragging() {
this.draggedPoint = null
Expand Down
1 change: 0 additions & 1 deletion ui/src/image_annotator_rect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export class RectAnnotator {
}
else if (this.movedRect || intersected?.isFocused) {
this.movedRect = this.movedRect || intersected
this.canvas.style.cursor = 'move'
if (!this.movedRect?.shape.rect) return

const
Expand Down

0 comments on commit 5559986

Please sign in to comment.