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

Class TooltipComponent

src/material/tooltip/tooltip.ts:968–1180  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

966 },
967})
968export class TooltipComponent implements OnDestroy {
969 private _changeDetectorRef = inject(ChangeDetectorRef);
970 protected _elementRef = inject<ElementRef<HTMLElement>>(ElementRef);
971
972 /* Whether the tooltip text overflows to multiple lines */
973 _isMultiline = false;
974
975 /** Message to display in the tooltip */
976 message!: string;
977
978 /** Classes to be added to the tooltip. */
979 tooltipClass!: string | string[] | {[key: string]: unknown};
980
981 /** The timeout ID of any current timer set to show the tooltip */
982 private _showTimeoutId: ReturnType<typeof setTimeout> | undefined;
983
984 /** The timeout ID of any current timer set to hide the tooltip */
985 private _hideTimeoutId: ReturnType<typeof setTimeout> | undefined;
986
987 /** Element that caused the tooltip to open. */
988 _triggerElement!: HTMLElement;
989
990 /** Amount of milliseconds to delay the closing sequence. */
991 _mouseLeaveHideDelay!: number;
992
993 /** Whether animations are currently disabled. */
994 private _animationsDisabled = _animationsDisabled();
995
996 /** Reference to the internal tooltip element. */
997 @ViewChild('tooltip', {
998 // Use a static query here since we interact directly with
999 // the DOM which can happen before `ngAfterViewInit`.
1000 static: true,
1001 })
1002 _tooltip!: ElementRef<HTMLElement>;
1003
1004 /** Whether interactions on the page should close the tooltip */
1005 private _closeOnInteraction = false;
1006
1007 /** Whether the tooltip is currently visible. */
1008 private _isVisible = false;
1009
1010 /** Subject for notifying that the tooltip has been hidden from the view */
1011 private readonly _onHide: Subject<void> = new Subject();
1012
1013 /** Name of the show animation and the class that toggles it. */
1014 private readonly _showAnimation = 'mat-mdc-tooltip-show';
1015
1016 /** Name of the hide animation and the class that toggles it. */
1017 private readonly _hideAnimation = 'mat-mdc-tooltip-hide';
1018
1019 /**
1020 * Shows the tooltip with an animation originating from the provided origin
1021 * @param delay Amount of milliseconds to the delay showing the tooltip.
1022 */
1023 show(delay: number): void {
1024 // Cancel the delayed hide if it is scheduled
1025 if (this._hideTimeoutId != null) {

Callers

nothing calls this directly

Calls 1

_animationsDisabledFunction · 0.90

Tested by

no test coverage detected