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

Function _updateTabScrollPosition

src/material/tabs/paginated-tab-header.ts:448–471  ·  view source on GitHub ↗

Performs the CSS transformation on the tab list that will cause the list to scroll.

()

Source from the content-addressed store, hash-verified

446
447 /** Performs the CSS transformation on the tab list that will cause the list to scroll. */
448 _updateTabScrollPosition() {
449 if (this.disablePagination) {
450 return;
451 }
452
453 const scrollDistance = this.scrollDistance;
454 const translateX = this._getLayoutDirection() === 'ltr' ? -scrollDistance : scrollDistance;
455
456 // Don't use `translate3d` here because we don't want to create a new layer. A new layer
457 // seems to cause flickering and overflow in Internet Explorer. For example, the ink bar
458 // and ripples will exceed the boundaries of the visible tab bar.
459 // See: https://github.com/angular/components/issues/10276
460 // We round the `transform` here, because transforms with sub-pixel precision cause some
461 // browsers to blur the content of the element.
462 this._tabList.nativeElement.style.transform = `translateX(${Math.round(translateX)}px)`;
463
464 // Setting the `transform` on IE will change the scroll offset of the parent, causing the
465 // position to be thrown off in some cases. We have to reset it ourselves to ensure that
466 // it doesn't get thrown off. Note that we scope it only to IE and Edge, because messing
467 // with the scroll position throws off Chrome 71+ in RTL mode (see #14689).
468 if (this._platform.TRIDENT || this._platform.EDGE) {
469 this._tabListContainer.nativeElement.scrollLeft = 0;
470 }
471 }
472
473 /** Sets the distance in pixels that the tab header should be transformed in the X-axis. */
474 get scrollDistance(): number {

Callers

nothing calls this directly

Calls 1

_getLayoutDirectionMethod · 0.80

Tested by

no test coverage detected