import { DOCUMENT } from '@angular/common' ; import { Inject , Injectable } from '@angular/core' ; import { ThyFullscreenRef } from './fullscreen-ref' ; import { ThyFullscreenConfig , ThyFullscreenMode } from './fullscreen.config' ; @ Injectable ( { providedIn : 'root' } ) export class ThyFullscreen { constructor ( @ Inject ( DOCUMENT ) protected document ) { } private fullscreenRefs : ThyFullscreenRef [ ] = [ ] ; param config launch < TResult = unknown > ( config ) { config . mode = config . mode || ThyFullscreenMode . immersive ; const fullscreenRef = new ThyFullscreenRef < TResult > ( this . document ) ; fullscreenRef . fullscreenConfig = config ; fullscreenRef . launch ( ) ; this . fullscreenRefs . push ( fullscreenRef ) ; fullscreenRef . afterExited ( ) . subscribe ( ( ) => { const index = this . fullscreenRefs . indexOf ( fullscreenRef ) ; if ( index > - 1 ) { this . fullscreenRefs . splice ( index , 1 ) ; } } ) ; return fullscreenRef ; } param config exit ( ) { const lastFullscreenRef = this . fullscreenRefs [ this . fullscreenRefs . length - 1 ] ; lastFullscreenRef . exit ( ) ; } }