@@ -422,10 +422,8 @@ export type TooltipVisibility = 'initial' | 'visible' | 'hidden';
422422 changeDetection : ChangeDetectionStrategy . OnPush ,
423423 animations : [
424424 trigger ( 'state' , [
425- state ( 'void' , style ( { transform : 'scale(0)' } ) ) ,
426- state ( 'initial' , style ( { transform : 'scale(0)' } ) ) ,
425+ state ( 'initial, void, hidden' , style ( { transform : 'scale(0)' } ) ) ,
427426 state ( 'visible' , style ( { transform : 'scale(1)' } ) ) ,
428- state ( 'hidden' , style ( { transform : 'scale(0)' } ) ) ,
429427 transition ( '* => visible' , animate ( '150ms cubic-bezier(0.0, 0.0, 0.2, 1)' ) ) ,
430428 transition ( '* => hidden' , animate ( '150ms cubic-bezier(0.4, 0.0, 1, 1)' ) ) ,
431429 ] )
@@ -455,7 +453,7 @@ export class TooltipComponent {
455453 _visibility : TooltipVisibility = 'initial' ;
456454
457455 /** Whether interactions on the page should close the tooltip */
458- _closeOnInteraction : boolean = false ;
456+ private _closeOnInteraction : boolean = false ;
459457
460458 /** The transform origin used in the animation for showing and hiding the tooltip */
461459 _transformOrigin : string = 'bottom' ;
@@ -477,21 +475,13 @@ export class TooltipComponent {
477475 clearTimeout ( this . _hideTimeoutId ) ;
478476 }
479477
480- // Body interactions should cancel the tooltip if there is a delay in showing.
481- this . _closeOnInteraction = true ;
482-
483478 this . _setTransformOrigin ( position ) ;
484479 this . _showTimeoutId = setTimeout ( ( ) => {
485480 this . _visibility = 'visible' ;
486481
487- // If this was set to true immediately, then a body click that triggers show() would
488- // trigger interaction and close the tooltip right after it was displayed.
489- this . _closeOnInteraction = false ;
490-
491482 // Mark for check so if any parent component has set the
492483 // ChangeDetectionStrategy to OnPush it will be checked anyways
493484 this . _markForCheck ( ) ;
494- setTimeout ( ( ) => this . _closeOnInteraction = true , 0 ) ;
495485 } , delay ) ;
496486 }
497487
@@ -507,7 +497,6 @@ export class TooltipComponent {
507497
508498 this . _hideTimeoutId = setTimeout ( ( ) => {
509499 this . _visibility = 'hidden' ;
510- this . _closeOnInteraction = false ;
511500
512501 // Mark for check so if any parent component has set the
513502 // ChangeDetectionStrategy to OnPush it will be checked anyways
@@ -543,10 +532,23 @@ export class TooltipComponent {
543532 }
544533 }
545534
546- _afterVisibilityAnimation ( e : AnimationEvent ) : void {
547- if ( e . toState === 'hidden' && ! this . isVisible ( ) ) {
535+ _animationStart ( ) {
536+ this . _closeOnInteraction = false ;
537+ }
538+
539+ _animationDone ( event : AnimationEvent ) : void {
540+ const toState = event . toState as TooltipVisibility ;
541+
542+ if ( toState === 'hidden' && ! this . isVisible ( ) ) {
548543 this . _onHide . next ( ) ;
549544 }
545+
546+ if ( toState === 'visible' || toState === 'hidden' ) {
547+ // Note: as of Angular 4.3, the animations module seems to fire the `start` callback before
548+ // the end if animations are disabled. Make this call async to ensure that it still fires
549+ // at the appropriate time.
550+ Promise . resolve ( ) . then ( ( ) => this . _closeOnInteraction = true ) ;
551+ }
550552 }
551553
552554 /**
0 commit comments