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

Method _getOrigin

src/material/tooltip/tooltip.ts:629–658  ·  view source on GitHub ↗

* Returns the origin position and a fallback position based on the user's position preference. * The fallback position is the inverse of the origin (e.g. `'below' -> 'above'`).

()

Source from the content-addressed store, hash-verified

627 * The fallback position is the inverse of the origin (e.g. `'below' -> 'above'`).
628 */
629 _getOrigin(): {main: OriginConnectionPosition; fallback: OriginConnectionPosition} {
630 const isLtr = !this._dir || this._dir.value == 'ltr';
631 const position = this.position;
632 let originPosition: OriginConnectionPosition;
633
634 if (position == 'above' || position == 'below') {
635 originPosition = {originX: 'center', originY: position == 'above' ? 'top' : 'bottom'};
636 } else if (
637 position == 'before' ||
638 (position == 'left' && isLtr) ||
639 (position == 'right' && !isLtr)
640 ) {
641 originPosition = {originX: 'start', originY: 'center'};
642 } else if (
643 position == 'after' ||
644 (position == 'right' && isLtr) ||
645 (position == 'left' && !isLtr)
646 ) {
647 originPosition = {originX: 'end', originY: 'center'};
648 } else if (typeof ngDevMode === 'undefined' || ngDevMode) {
649 throw getMatTooltipInvalidPositionError(position);
650 }
651
652 const {x, y} = this._invertPosition(originPosition!.originX, originPosition!.originY);
653
654 return {
655 main: originPosition!,
656 fallback: {originX: x, originY: y},
657 };
658 }
659
660 /** Returns the overlay position and a fallback position based on the user's preference */
661 _getOverlayPosition(): {main: OverlayConnectionPosition; fallback: OverlayConnectionPosition} {

Callers 2

_updatePositionMethod · 0.95
tooltip.spec.tsFile · 0.45

Calls 2

_invertPositionMethod · 0.95

Tested by

no test coverage detected