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

Method alignToElement

src/material/tabs/ink-bar.ts:55–72  ·  view source on GitHub ↗

Aligns the ink bar to a DOM node.

(element: HTMLElement)

Source from the content-addressed store, hash-verified

53
54 /** Aligns the ink bar to a DOM node. */
55 alignToElement(element: HTMLElement) {
56 const correspondingItem = this._items.find(item => item.elementRef.nativeElement === element);
57 const currentItem = this._currentItem;
58
59 if (correspondingItem === currentItem) {
60 return;
61 }
62
63 currentItem?.deactivateInkBar();
64
65 if (correspondingItem) {
66 const domRect = currentItem?.elementRef.nativeElement.getBoundingClientRect?.();
67
68 // The ink bar won't animate unless we give it the `DOMRect` of the previous item.
69 correspondingItem.activateInkBar(domRect);
70 this._currentItem = correspondingItem;
71 }
72 }
73}
74
75@Directive()

Callers 1

Calls 3

deactivateInkBarMethod · 0.80
getBoundingClientRectMethod · 0.80
activateInkBarMethod · 0.80

Tested by

no test coverage detected