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

Function _itemsResized

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

Sends any changes that could affect the layout of the items.

()

Source from the content-addressed store, hash-verified

270
271 /** Sends any changes that could affect the layout of the items. */
272 private _itemsResized(): Observable<ResizeObserverEntry[]> {
273 if (typeof ResizeObserver !== 'function') {
274 return EMPTY;
275 }
276
277 return this._items.changes.pipe(
278 startWith(this._items),
279 switchMap(
280 (tabItems: QueryList<MatPaginatedTabHeaderItem>) =>
281 new Observable((observer: Observer<ResizeObserverEntry[]>) =>
282 this._ngZone.runOutsideAngular(() => {
283 const resizeObserver = new ResizeObserver(entries => observer.next(entries));
284 tabItems.forEach(item => resizeObserver.observe(item.elementRef.nativeElement));
285 return () => {
286 resizeObserver.disconnect();
287 };
288 }),
289 ),
290 ),
291 // Skip the first emit since the resize observer emits when an item
292 // is observed for new items when the tab is already inserted
293 skip(1),
294 // Skip emissions where all the elements are invisible since we don't want
295 // the header to try and re-render with invalid measurements. See #25574.
296 filter(entries => entries.some(e => e.contentRect.width > 0 && e.contentRect.height > 0)),
297 );
298 }
299
300 ngAfterContentChecked(): void {
301 // If the number of tab labels have changed, check if scrolling should be enabled

Callers

nothing calls this directly

Calls 3

nextMethod · 0.45
observeMethod · 0.45
disconnectMethod · 0.45

Tested by

no test coverage detected