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

Method _updatePositionInParent

src/material/sidenav/drawer.ts:650–669  ·  view source on GitHub ↗

* Updates the position of the drawer in the DOM. We need to move the element around ourselves * when it's in the `end` position so that it comes after the content and the visual order * matches the tab order. We also need to be able to move it back to `start` if the sidenav * started off as

(newPosition: 'start' | 'end')

Source from the content-addressed store, hash-verified

648 * started off as `end` and was changed to `start`.
649 */
650 private _updatePositionInParent(newPosition: 'start' | 'end'): void {
651 // Don't move the DOM node around on the server, because it can throw off hydration.
652 if (!this._platform.isBrowser) {
653 return;
654 }
655
656 const element = this._elementRef.nativeElement;
657 const parent = element.parentNode!;
658
659 if (newPosition === 'end') {
660 if (!this._anchor) {
661 this._anchor = this._doc.createComment('mat-drawer-anchor')!;
662 parent.insertBefore(this._anchor!, element);
663 }
664
665 parent.appendChild(element);
666 } else if (this._anchor) {
667 this._anchor.parentNode!.insertBefore(element, this._anchor);
668 }
669 }
670
671 /** Event handler for animation events. */
672 private _handleTransitionEvent = (event: TransitionEvent) => {

Callers 2

positionMethod · 0.95
ngAfterViewInitMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected