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

Method _updatePositionInParent

src/material/sidenav/drawer.ts:670–689  ·  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

668 * started off as `end` and was changed to `start`.
669 */
670 private _updatePositionInParent(newPosition: 'start' | 'end'): void {
671 // Don't move the DOM node around on the server, because it can throw off hydration.
672 if (!this._platform.isBrowser) {
673 return;
674 }
675
676 const element = this._elementRef.nativeElement;
677 const parent = element.parentNode!;
678
679 if (newPosition === 'end') {
680 if (!this._anchor) {
681 this._anchor = this._doc.createComment('mat-drawer-anchor')!;
682 parent.insertBefore(this._anchor!, element);
683 }
684
685 parent.appendChild(element);
686 } else if (this._anchor) {
687 this._anchor.parentNode!.insertBefore(element, this._anchor);
688 }
689 }
690
691 /** Event handler for animation events. */
692 private _handleTransitionEvent = (event: TransitionEvent) => {

Callers 2

positionMethod · 0.95
ngAfterViewInitMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected