@@ -46,9 +46,9 @@ const EXIT_ANIMATION = '_mat-bottom-sheet-exit';
4646 '[attr.role]' : '_config.role' ,
4747 '[attr.aria-modal]' : '_config.ariaModal' ,
4848 '[attr.aria-label]' : '_config.ariaLabel' ,
49- '(animationstart)' : '_handleAnimationEvent(true, $event.animationName)' ,
50- '(animationend)' : '_handleAnimationEvent(false, $event.animationName)' ,
51- '(animationcancel)' : '_handleAnimationEvent(false, $event.animationName)' ,
49+ '(animationstart)' : '_handleAnimationEvent(true, $event.animationName, $event.target )' ,
50+ '(animationend)' : '_handleAnimationEvent(false, $event.animationName, $event.target )' ,
51+ '(animationcancel)' : '_handleAnimationEvent(false, $event.animationName, $event.target )' ,
5252 } ,
5353 imports : [ CdkPortalOutlet ] ,
5454} )
@@ -125,8 +125,8 @@ export class MatBottomSheetContainer extends CdkDialogContainer implements OnDes
125125
126126 private _simulateAnimation ( name : typeof ENTER_ANIMATION | typeof EXIT_ANIMATION ) {
127127 this . _ngZone . run ( ( ) => {
128- this . _handleAnimationEvent ( true , name ) ;
129- setTimeout ( ( ) => this . _handleAnimationEvent ( false , name ) ) ;
128+ this . _handleAnimationEvent ( true , name , this . _elementRef . nativeElement ) ;
129+ setTimeout ( ( ) => this . _handleAnimationEvent ( false , name , this . _elementRef . nativeElement ) ) ;
130130 } ) ;
131131 }
132132
@@ -139,15 +139,21 @@ export class MatBottomSheetContainer extends CdkDialogContainer implements OnDes
139139 super . _trapFocus ( { preventScroll : true } ) ;
140140 }
141141
142- protected _handleAnimationEvent ( isStart : boolean , animationName : string ) {
143- const isEnter = animationName === ENTER_ANIMATION ;
144- const isExit = animationName === EXIT_ANIMATION ;
145-
146- if ( isEnter || isExit ) {
147- this . _animationStateChanged . emit ( {
148- toState : isEnter ? 'visible' : 'hidden' ,
149- phase : isStart ? 'start' : 'done' ,
150- } ) ;
142+ protected _handleAnimationEvent (
143+ isStart : boolean ,
144+ animationName : string ,
145+ target : EventTarget | null ,
146+ ) {
147+ if ( target === this . _elementRef . nativeElement ) {
148+ const isEnter = animationName === ENTER_ANIMATION ;
149+ const isExit = animationName === EXIT_ANIMATION ;
150+
151+ if ( isEnter || isExit ) {
152+ this . _animationStateChanged . emit ( {
153+ toState : isEnter ? 'visible' : 'hidden' ,
154+ phase : isStart ? 'start' : 'done' ,
155+ } ) ;
156+ }
151157 }
152158 }
153159}
0 commit comments