@@ -55,8 +55,7 @@ export class MdbTooltipDirective implements OnInit, OnDestroy {
5555 constructor (
5656 private _overlay : Overlay ,
5757 private _overlayPositionBuilder : OverlayPositionBuilder ,
58- private _elementRef : ElementRef ,
59- private _renderer : Renderer2
58+ private _elementRef : ElementRef
6059 ) { }
6160
6261 ngOnInit ( ) : void {
@@ -65,11 +64,10 @@ export class MdbTooltipDirective implements OnInit, OnDestroy {
6564 }
6665
6766 this . _bindTriggerEvents ( ) ;
68- this . _createOverlay ( ) ;
6967 }
7068
7169 ngOnDestroy ( ) : void {
72- if ( this . _open ) {
70+ if ( this . _open || this . _showTimeout ) {
7371 this . hide ( ) ;
7472 }
7573
@@ -172,15 +170,14 @@ export class MdbTooltipDirective implements OnInit, OnDestroy {
172170 }
173171
174172 show ( ) : void {
175- if ( this . _open ) {
173+ if ( this . _hideTimeout || this . _open ) {
176174 this . _overlayRef . detach ( ) ;
177- }
178-
179- if ( this . _hideTimeout ) {
180175 clearTimeout ( this . _hideTimeout ) ;
181176 this . _hideTimeout = null ;
182177 }
183178
179+ this . _createOverlay ( ) ;
180+
184181 this . _showTimeout = setTimeout ( ( ) => {
185182 const tooltipPortal = new ComponentPortal ( MdbTooltipComponent ) ;
186183
@@ -200,24 +197,29 @@ export class MdbTooltipDirective implements OnInit, OnDestroy {
200197 }
201198
202199 hide ( ) : void {
203- if ( ! this . _open ) {
204- return ;
205- }
206-
207200 if ( this . _showTimeout ) {
208201 clearTimeout ( this . _showTimeout ) ;
209202 this . _showTimeout = null ;
203+ } else {
204+ return ;
210205 }
211206
212207 this . _hideTimeout = setTimeout ( ( ) => {
213208 this . tooltipHide . emit ( this ) ;
214- this . _tooltipRef . instance . _hidden . pipe ( first ( ) ) . subscribe ( ( ) => {
209+
210+ if ( ! this . _tooltipRef ) {
215211 this . _overlayRef . detach ( ) ;
216212 this . _open = false ;
217- this . tooltipShown . emit ( this ) ;
218- } ) ;
219- this . _tooltipRef . instance . animationState = 'hidden' ;
220- this . _tooltipRef . instance . markForCheck ( ) ;
213+ this . tooltipHidden . emit ( this ) ;
214+ } else {
215+ this . _tooltipRef . instance . _hidden . pipe ( first ( ) ) . subscribe ( ( ) => {
216+ this . _overlayRef . detach ( ) ;
217+ this . _open = false ;
218+ this . tooltipHidden . emit ( this ) ;
219+ } ) ;
220+ this . _tooltipRef . instance . animationState = 'hidden' ;
221+ this . _tooltipRef . instance . markForCheck ( ) ;
222+ }
221223 } , this . delayHide ) ;
222224 }
223225
0 commit comments