namespace viewer { interface HTMLEventListener { ( event ) : boolean ; } /**
     * Auxiliary class for blocking and unblocking events on a HTML element. Example for blocking the contextmenu:
     * ```
     * blocker = new gloperate.EventBlocker(element);
     * blocker.block('contextmenu');
     * ```
     */ export class EventBlocker { /**
         * Lookup table for blocked events and their listener.
         */ private _blockListenerByEvent = new Map < string , HTMLEventListener > ( ) ; /**
         * Element associated to this blocker.
         */ protected _element : HTMLElement ; param element param events constructor ( element , events ? ) { this . _element = element ; if ( events === undefined ) { return ; } for ( const event of events ) { this . block ( event ) ; } } param eventIdentifier block ( eventIdentifier ) { if ( this . _blockListenerByEvent . has ( eventIdentifier ) ) { return ; } this . _blockListenerByEvent . set ( eventIdentifier , ( event ) : boolean => { event . preventDefault ( ) ; event . stopPropagation ( ) ; return false ; } ) ; this . _element . addEventListener ( eventIdentifier , this . _blockListenerByEvent . get ( eventIdentifier ) as HTMLEventListener ) ; } param eventIdentifier unblock ( eventIdentifier ) { if ( ! this . _blockListenerByEvent . has ( eventIdentifier ) ) { return ; } this . _element . removeEventListener ( eventIdentifier , this . _blockListenerByEvent . get ( eventIdentifier ) as HTMLEventListener ) ; this . _blockListenerByEvent . delete ( eventIdentifier ) ; } } } export = viewer ;