import { ReactPictureAnnotation } from "index" ; import { IAnnotationState } from "./AnnotationState" ; import { DefaultAnnotationState } from "./DefaultAnnotationState" ; export default class DraggingAnnotationState implements IAnnotationState { private readonly context : ReactPictureAnnotation ; constructor ( context ) { this . context = context ; } public onMouseDown = ( ) => undefined ; public onMouseMove = ( positionX , positionY ) => { 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 ( ) ; }