1
1
import {
2
- Directive , ElementRef , Input , ChangeDetectorRef , Optional , HostBinding , Inject , OnDestroy
2
+ Directive , ElementRef , Input , ChangeDetectorRef , Optional , HostBinding , Inject , OnDestroy , inject , DOCUMENT
3
3
} from '@angular/core' ;
4
4
import { IgxOverlayService } from '../../services/overlay/overlay' ;
5
5
import { OverlaySettings } from '../../services/public_api' ;
@@ -110,6 +110,7 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy
110
110
public tooltipTarget : IgxTooltipTargetDirective ;
111
111
112
112
private _destroy$ = new Subject < boolean > ( ) ;
113
+ private _document = inject ( DOCUMENT ) ;
113
114
114
115
/** @hidden */
115
116
constructor (
@@ -122,18 +123,18 @@ export class IgxTooltipDirective extends IgxToggleDirective implements OnDestroy
122
123
123
124
this . onDocumentTouchStart = this . onDocumentTouchStart . bind ( this ) ;
124
125
this . overlayService . opening . pipe ( takeUntil ( this . _destroy$ ) ) . subscribe ( ( ) => {
125
- document . addEventListener ( 'touchstart' , this . onDocumentTouchStart , { passive : true } ) ;
126
+ this . _document . addEventListener ( 'touchstart' , this . onDocumentTouchStart , { passive : true } ) ;
126
127
} ) ;
127
128
this . overlayService . closed . pipe ( takeUntil ( this . _destroy$ ) ) . subscribe ( ( ) => {
128
- document . removeEventListener ( 'touchstart' , this . onDocumentTouchStart ) ;
129
+ this . _document . removeEventListener ( 'touchstart' , this . onDocumentTouchStart ) ;
129
130
} ) ;
130
131
}
131
132
132
133
/** @hidden */
133
134
public override ngOnDestroy ( ) {
134
135
super . ngOnDestroy ( ) ;
135
136
136
- document . removeEventListener ( 'touchstart' , this . onDocumentTouchStart ) ;
137
+ this . _document . removeEventListener ( 'touchstart' , this . onDocumentTouchStart ) ;
137
138
this . _destroy$ . next ( true ) ;
138
139
this . _destroy$ . complete ( ) ;
139
140
}
0 commit comments