Sets up the transition events.
()
| 219 | |
| 220 | /** Sets up the transition events. */ |
| 221 | private _bindTransitionEvents() { |
| 222 | this._ngZone.runOutsideAngular(() => { |
| 223 | const element = this._elementRef.nativeElement; |
| 224 | const transitionDone = (event: TransitionEvent) => { |
| 225 | if (event.target === this._contentElement?.nativeElement) { |
| 226 | this._elementRef.nativeElement.classList.remove('mat-tab-body-animating'); |
| 227 | |
| 228 | // Only fire the actual callback when a transition is fully finished, |
| 229 | // otherwise the content can jump around when the next transition starts. |
| 230 | if (event.type === 'transitionend') { |
| 231 | this._transitionDone(); |
| 232 | } |
| 233 | } |
| 234 | }; |
| 235 | |
| 236 | this._eventCleanups = [ |
| 237 | this._renderer.listen(element, 'transitionstart', (event: TransitionEvent) => { |
| 238 | if (event.target === this._contentElement?.nativeElement) { |
| 239 | this._elementRef.nativeElement.classList.add('mat-tab-body-animating'); |
| 240 | this._transitionStarted(); |
| 241 | } |
| 242 | }), |
| 243 | this._renderer.listen(element, 'transitionend', transitionDone), |
| 244 | this._renderer.listen(element, 'transitioncancel', transitionDone), |
| 245 | ]; |
| 246 | }); |
| 247 | } |
| 248 | |
| 249 | /** Called when a transition has started. */ |
| 250 | private _transitionStarted() { |
no test coverage detected