import { ReactPictureAnnotation } from "index"; import { IAnnotationState } from "./AnnotationState"; import { DefaultAnnotationState } from "./DefaultAnnotationState"; export default class DraggingAnnotationState implements IAnnotationState { private readonly context: ReactPictureAnnotation; constructor(context: ReactPictureAnnotation) { this.context = context; } public onMouseDown = () => undefined; public onMouseMove = (positionX: number, positionY: number) => { const { shapes } = this.context; const currentShape = shapes[shapes.length - 1]; currentShape.onDrag(positionX, positionY); }; public onMouseUp = () => { const { setAnnotationState } = this.context; setAnnotationState(new DefaultAnnotationState(this.context)); }; public onMouseLeave = () => this.onMouseUp(); }