MCPcopy Create free account
hub / github.com/angular/components / _bindTransitionEvents

Method _bindTransitionEvents

src/material/tabs/tab-body.ts:221–247  ·  view source on GitHub ↗

Sets up the transition events.

()

Source from the content-addressed store, hash-verified

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() {

Callers 1

ngOnInitMethod · 0.95

Calls 3

_transitionStartedMethod · 0.95
listenMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected