@@ -53,6 +53,7 @@ export type BoardActions = {
5353 retrieveObjectContent : (
5454 id : string ,
5555 ) => { angle : number ; content : string | undefined } | null ;
56+ retrieveLastPointerPosition : ( ) => { x : number ; y : number } ;
5657} ;
5758
5859const Board = React . forwardRef < BoardActions , BoardProps > (
@@ -74,6 +75,9 @@ const Board = React.forwardRef<BoardActions, BoardProps>(
7475 ) => {
7576 // Set board actions
7677 React . useImperativeHandle ( ref , ( ) => ( {
78+ retrieveLastPointerPosition ( ) {
79+ return lastPointerPosition ;
80+ } ,
7781 resetZoom ( ) {
7882 editor ?. canvas . setViewportTransform ( [ 1 , 0 , 0 , 1 , 0 , 0 ] ) ;
7983 setCurrentZoom ( 100 ) ;
@@ -410,6 +414,11 @@ const Board = React.forwardRef<BoardActions, BoardProps>(
410414 height : 0 ,
411415 } ) ;
412416
417+ const [ lastPointerPosition , setLastPointerPosition ] = useState ( {
418+ x : 0 ,
419+ y : 0 ,
420+ } ) ;
421+
413422 const [ isInDrawingMode , setIsInDrawingMode ] = useState ( false ) ;
414423
415424 const [ objectHelper , setObjectHelper ] = useState < {
@@ -941,7 +950,8 @@ const Board = React.forwardRef<BoardActions, BoardProps>(
941950 "mouse:down" ,
942951 function ( this : fabricTypes . CanvasAnnotationState , opt ) {
943952 const evt = opt . e ;
944-
953+ const pointer = editor . canvas . getPointer ( opt . e ) ;
954+ setLastPointerPosition ( pointer ) ;
945955 if ( ( evt . button === 0 && ! opt . target ) || evt . button === 1 ) {
946956 this . isDragging = true ;
947957 this . selection = false ;
0 commit comments