MCPcopy Index your code
hub / github.com/angular/components / _getOverlayPosition

Method _getOverlayPosition

src/material/tooltip/tooltip.ts:661–692  ·  view source on GitHub ↗

Returns the overlay position and a fallback position based on the user's preference

()

Source from the content-addressed store, hash-verified

659
660 /** Returns the overlay position and a fallback position based on the user's preference */
661 _getOverlayPosition(): {main: OverlayConnectionPosition; fallback: OverlayConnectionPosition} {
662 const isLtr = !this._dir || this._dir.value == 'ltr';
663 const position = this.position;
664 let overlayPosition: OverlayConnectionPosition;
665
666 if (position == 'above') {
667 overlayPosition = {overlayX: 'center', overlayY: 'bottom'};
668 } else if (position == 'below') {
669 overlayPosition = {overlayX: 'center', overlayY: 'top'};
670 } else if (
671 position == 'before' ||
672 (position == 'left' && isLtr) ||
673 (position == 'right' && !isLtr)
674 ) {
675 overlayPosition = {overlayX: 'end', overlayY: 'center'};
676 } else if (
677 position == 'after' ||
678 (position == 'right' && isLtr) ||
679 (position == 'left' && !isLtr)
680 ) {
681 overlayPosition = {overlayX: 'start', overlayY: 'center'};
682 } else if (typeof ngDevMode === 'undefined' || ngDevMode) {
683 throw getMatTooltipInvalidPositionError(position);
684 }
685
686 const {x, y} = this._invertPosition(overlayPosition!.overlayX, overlayPosition!.overlayY);
687
688 return {
689 main: overlayPosition!,
690 fallback: {overlayX: x, overlayY: y},
691 };
692 }
693
694 /** Updates the tooltip message and repositions the overlay according to the new message length */
695 private _updateTooltipMessage() {

Callers 2

_updatePositionMethod · 0.95
tooltip.spec.tsFile · 0.45

Calls 2

_invertPositionMethod · 0.95

Tested by

no test coverage detected