1+ import { DOCUMENT } from '@angular/common' ;
12import {
2- Directive , ElementRef , Input , ChangeDetectorRef , Optional , HostBinding , Inject , OnDestroy
3+ Directive , ElementRef , Input , ChangeDetectorRef , Optional , HostBinding , Inject , OnDestroy , inject
34} from '@angular/core' ;
45import { IgxOverlayService } from '../../services/overlay/overlay' ;
56import { OverlaySettings } from '../../services/public_api' ;
@@ -110,6 +111,7 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy
110111 public tooltipTarget : IgxTooltipTargetDirective ;
111112
112113 private _destroy$ = new Subject < boolean > ( ) ;
114+ private _document = inject ( DOCUMENT ) ;
113115
114116 /** @hidden */
115117 constructor (
@@ -122,18 +124,18 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy
122124
123125 this . onDocumentTouchStart = this . onDocumentTouchStart . bind ( this ) ;
124126 this . overlayService . opening . pipe ( takeUntil ( this . _destroy$ ) ) . subscribe ( ( ) => {
125- document . addEventListener ( 'touchstart' , this . onDocumentTouchStart , { passive : true } ) ;
127+ this . _document . addEventListener ( 'touchstart' , this . onDocumentTouchStart , { passive : true } ) ;
126128 } ) ;
127129 this . overlayService . closed . pipe ( takeUntil ( this . _destroy$ ) ) . subscribe ( ( ) => {
128- document . removeEventListener ( 'touchstart' , this . onDocumentTouchStart ) ;
130+ this . _document . removeEventListener ( 'touchstart' , this . onDocumentTouchStart ) ;
129131 } ) ;
130132 }
131133
132134 /** @hidden */
133135 public override ngOnDestroy ( ) {
134136 super . ngOnDestroy ( ) ;
135137
136- document . removeEventListener ( 'touchstart' , this . onDocumentTouchStart ) ;
138+ this . _document . removeEventListener ( 'touchstart' , this . onDocumentTouchStart ) ;
137139 this . _destroy$ . next ( true ) ;
138140 this . _destroy$ . complete ( ) ;
139141 }
0 commit comments