import { AnnotationStyle } from './electron/ElectronScreenshots' ; import { StyleRestore } from './electron/ElectronScreenshots' ; import { Promises } from '../util/Promises' ; const MIN_PAINT_INTERVAL = 1000 / 60 ; export class AnnotationToggler { private SELECTOR = ".page .pagemark, .page .text-highlight, .page .area-highlight" ; private annotationStyles : AnnotationStyle [ ] = [ ] ; private getAnnotationElements ( ) { return Array . from ( document . querySelectorAll ( this . SELECTOR ) ) ; } public async hide ( ) { await Promises . requestAnimationFrame ( ( ) => this . hideAnnotations ( ) ) ; await Promises . waitFor ( MIN_PAINT_INTERVAL ) ; } private hideAnnotations ( ) { for ( const annotationElement of this . getAnnotationElements ( ) ) { const styleRestore = { visibility : annotationElement . style . visibility } ; annotationElement . style . visibility = 'hidden' ; this . annotationStyles . push ( { element : annotationElement , styleRestore } ) ; } } public show ( ) { for ( const annotationStyle of this . annotationStyles ) { annotationStyle . element . style . visibility = annotationStyle . styleRestore . visibility ! ; } } }