@@ -28,9 +28,9 @@ import {
28
28
import { AnimationEvent } from '@angular/animations' ;
29
29
import { TemplatePortal , CdkPortalOutlet , PortalHostDirective } from '@angular/cdk/portal' ;
30
30
import { Directionality , Direction } from '@angular/cdk/bidi' ;
31
- import { Subscription , Subject } from 'rxjs' ;
31
+ import { Subscription } from 'rxjs' ;
32
32
import { matTabsAnimations } from './tabs-animations' ;
33
- import { startWith , distinctUntilChanged } from 'rxjs/operators' ;
33
+ import { startWith } from 'rxjs/operators' ;
34
34
35
35
/**
36
36
* These position states are used internally as animation states for the tab body. Setting the
@@ -125,9 +125,6 @@ export class MatTabBody implements OnInit, OnDestroy {
125
125
/** Tab body position state. Used by the animation trigger for the current state. */
126
126
_position : MatTabBodyPositionState ;
127
127
128
- /** Emits when an animation on the tab is complete. */
129
- _translateTabComplete = new Subject < AnimationEvent > ( ) ;
130
-
131
128
/** Event emitted when the tab begins to animate towards the center as the active tab. */
132
129
@Output ( ) readonly _onCentering : EventEmitter < number > = new EventEmitter < number > ( ) ;
133
130
@@ -169,21 +166,6 @@ export class MatTabBody implements OnInit, OnDestroy {
169
166
changeDetectorRef . markForCheck ( ) ;
170
167
} ) ;
171
168
}
172
-
173
- // Ensure that we get unique animation events, because the `.done` callback can get
174
- // invoked twice in some browsers. See https://github.com/angular/angular/issues/24084.
175
- this . _translateTabComplete . pipe ( distinctUntilChanged ( ( x , y ) => {
176
- return x . fromState === y . fromState && x . toState === y . toState ;
177
- } ) ) . subscribe ( event => {
178
- // If the transition to the center is complete, emit an event.
179
- if ( this . _isCenterPosition ( event . toState ) && this . _isCenterPosition ( this . _position ) ) {
180
- this . _onCentered . emit ( ) ;
181
- }
182
-
183
- if ( this . _isCenterPosition ( event . fromState ) && ! this . _isCenterPosition ( this . _position ) ) {
184
- this . _afterLeavingCenter . emit ( ) ;
185
- }
186
- } ) ;
187
169
}
188
170
189
171
/**
@@ -198,17 +180,27 @@ export class MatTabBody implements OnInit, OnDestroy {
198
180
199
181
ngOnDestroy ( ) {
200
182
this . _dirChangeSubscription . unsubscribe ( ) ;
201
- this . _translateTabComplete . complete ( ) ;
202
183
}
203
184
204
- _onTranslateTabStarted ( event : AnimationEvent ) : void {
205
- const isCentering = this . _isCenterPosition ( event . toState ) ;
185
+ _onTranslateTabStarted ( e : AnimationEvent ) : void {
186
+ const isCentering = this . _isCenterPosition ( e . toState ) ;
206
187
this . _beforeCentering . emit ( isCentering ) ;
207
188
if ( isCentering ) {
208
189
this . _onCentering . emit ( this . _elementRef . nativeElement . clientHeight ) ;
209
190
}
210
191
}
211
192
193
+ _onTranslateTabComplete ( e : AnimationEvent ) : void {
194
+ // If the transition to the center is complete, emit an event.
195
+ if ( this . _isCenterPosition ( e . toState ) && this . _isCenterPosition ( this . _position ) ) {
196
+ this . _onCentered . emit ( ) ;
197
+ }
198
+
199
+ if ( this . _isCenterPosition ( e . fromState ) && ! this . _isCenterPosition ( this . _position ) ) {
200
+ this . _afterLeavingCenter . emit ( ) ;
201
+ }
202
+ }
203
+
212
204
/** The text direction of the containing app. */
213
205
_getLayoutDirection ( ) : Direction {
214
206
return this . _dir && this . _dir . value === 'rtl' ? 'rtl' : 'ltr' ;
0 commit comments