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

Method _updateCurrentPositionClass

src/material/tooltip/tooltip.ts:746–776  ·  view source on GitHub ↗

Updates the class on the overlay panel based on the current position of the tooltip.

(connectionPair: ConnectionPositionPair)

Source from the content-addressed store, hash-verified

744
745 /** Updates the class on the overlay panel based on the current position of the tooltip. */
746 private _updateCurrentPositionClass(connectionPair: ConnectionPositionPair): void {
747 const {overlayY, originX, originY} = connectionPair;
748 let newPosition: TooltipPosition;
749
750 // If the overlay is in the middle along the Y axis,
751 // it means that it's either before or after.
752 if (overlayY === 'center') {
753 // Note that since this information is used for styling, we want to
754 // resolve `start` and `end` to their real values, otherwise consumers
755 // would have to remember to do it themselves on each consumption.
756 if (this._dir && this._dir.value === 'rtl') {
757 newPosition = originX === 'end' ? 'left' : 'right';
758 } else {
759 newPosition = originX === 'start' ? 'left' : 'right';
760 }
761 } else {
762 newPosition = overlayY === 'bottom' && originY === 'top' ? 'above' : 'below';
763 }
764
765 if (newPosition !== this._currentPosition) {
766 const overlayRef = this._overlayRef;
767
768 if (overlayRef) {
769 const classPrefix = `${this._cssClassPrefix}-${PANEL_CLASS}-`;
770 overlayRef.removePanelClass(classPrefix + this._currentPosition);
771 overlayRef.addPanelClass(classPrefix + newPosition);
772 }
773
774 this._currentPosition = newPosition;
775 }
776 }
777
778 /** Binds the pointer events to the tooltip trigger. */
779 private _setupPointerEnterEventsIfNeeded() {

Callers 1

_createOverlayMethod · 0.95

Calls 2

removePanelClassMethod · 0.45
addPanelClassMethod · 0.45

Tested by

no test coverage detected