interface Options { onMouseDown : ( e : MouseEvent ) => void ; onMouseMove : ( e : MouseEvent ) => void ; onMouseUp : ( e : MouseEvent ) => void ; } /**
 * Helper for handling down/up/move events.
 */ export const useOnMouse = ( el , { onMouseDown , onMouseMove , onMouseUp } ) => { const handleDown = ( e ) => { document . addEventListener ( 'mouseup' , handleUp ) ; document . addEventListener ( 'mousemove' , handleMove ) ; onMouseDown ( e ) ; } ; const handleUp = ( e ) => { document . removeEventListener ( 'mousemove' , handleMove ) ; document . removeEventListener ( 'mouseup' , handleUp ) ; onMouseUp ( e ) ; } ; const handleMove = ( e ) => { onMouseMove ( e ) ; } ; el . addEventListener ( 'mousedown' , handleDown ) ; } ;