let events = { down : 'mousedown' , move : 'mousemove' , up : 'mouseup mouseleave' } ; if ( typeof window !== 'undefined' ) { if ( typeof window . PointerEvent === 'function' ) { events = { down : 'pointerdown' , move : 'pointermove' , up : 'pointerup pointerleave pointercancel' } ; } else if ( typeof window . TouchEvent === 'function' ) { events = { down : 'touchstart' , move : 'touchmove' , up : 'touchend touchcancel' } ; } } export { events as eventNames } ; type PointerEventName = 'pointerdown' | 'pointermove' | 'pointerup' | 'pointerleave' | 'pointercancel' ; export function onPointer ( event , elem , handler , eventOpts ? ) { events [ event ] . split ( ' ' ) . forEach ( ( name ) => { ; ( elem as HTMLElement ) . addEventListener < PointerEventName > ( name as PointerEventName , handler , eventOpts ) ; } ) ; } export function destroyPointer ( event , elem , handler ) { events [ event ] . split ( ' ' ) . forEach ( ( name ) => { ; ( elem as HTMLElement ) . removeEventListener < PointerEventName > ( name as PointerEventName , handler ) ; } ) ; }