import Vue from 'vue' ; export abstract class Events extends Vue { static customEventListeners : any = { } ; protected events : any = { } ; protected constructor ( ) { super ( ) ; let events = { pointerdown : this . pointerdown , pointermove : this . pointermove , pointerup : this . pointerup , pointerenter : this . pointerenter , pointerleave : this . pointerleave } ; if ( ! window . PointerEvent ) { events = { mousedown : this . pointerdown , mousemove : this . pointermove , mouseup : this . pointerup , mouseenter : this . pointerenter , mouseleave : this . pointerleave , touchstart : this . touchstart , touchmove : this . touchmove , touchend : this . touchend } ; } for ( const i in events ) { if ( Object . prototype . hasOwnProperty . call ( events , i ) ) { this . registerEvent ( i as keyof HTMLElementEventMap , ( evt ) => { events [ i ] . call ( this , evt ) ; } ) ; } } } param event param callback public registerEvent ( event , callback ) { const name = event . toString ( ) . toLowerCase ( ) ; this . events [ name ] = { name : name , callback : callback } ; } param event param evt public fireEvent ( event , evt ) { for ( const i in this . events ) { if ( Object . prototype . hasOwnProperty . call ( this . events , i ) ) { if ( event . toUpperCase ( ) === i . toUpperCase ( ) ) { this . events [ i ] . callback . call ( this , evt ) ; break ; } } } } return public static removeCustomEventListeners ( ) { Events . customEventListeners = { } ; } param event protected abstract pointerdown ( event ) ; param event protected abstract pointermove ( event ) ; param event protected abstract pointerup ( event ) ; param event protected abstract pointerenter ( event ) ; param event protected abstract pointerleave ( event ) ; param event protected abstract touchstart ( event ) ; param event protected abstract touchmove ( event ) ; param event protected abstract touchend ( event ) ; }