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

Method _computePositionAnimationState

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

Computes the position state that will be used for the tab-body animation trigger.

(dir: Direction = this._getLayoutDirection())

Source from the content-addressed store, hash-verified

282
283 /** Computes the position state that will be used for the tab-body animation trigger. */
284 private _computePositionAnimationState(dir: Direction = this._getLayoutDirection()) {
285 this._previousPosition = this._position;
286
287 if (this._positionIndex < 0) {
288 this._position = dir == 'ltr' ? 'left' : 'right';
289 } else if (this._positionIndex > 0) {
290 this._position = dir == 'ltr' ? 'right' : 'left';
291 } else {
292 this._position = 'center';
293 }
294
295 if (this._animationsDisabled()) {
296 this._simulateTransitionEvents();
297 } else if (
298 this._initialized &&
299 (this._position === 'center' || this._previousPosition === 'center')
300 ) {
301 // The transition events are load-bearing and in some cases they might not fire (e.g.
302 // tests setting `* {transition: none}` to disable animations). This timeout will simulate
303 // them if a transition doesn't start within a certain amount of time.
304 clearTimeout(this._fallbackTimer);
305 this._fallbackTimer = this._ngZone.runOutsideAngular(() =>
306 setTimeout(() => this._simulateTransitionEvents(), 100),
307 );
308 }
309 }
310
311 /** Simulates the body's transition events in an environment where they might not fire. */
312 private _simulateTransitionEvents() {

Callers 2

positionMethod · 0.95
constructorMethod · 0.95

Calls 3

_getLayoutDirectionMethod · 0.95
_animationsDisabledMethod · 0.95

Tested by

no test coverage detected