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

Method _toggleVisibility

src/material/tooltip/tooltip.ts:1143–1179  ·  view source on GitHub ↗

Toggles the visibility of the tooltip element.

(isVisible: boolean)

Source from the content-addressed store, hash-verified

1141
1142 /** Toggles the visibility of the tooltip element. */
1143 private _toggleVisibility(isVisible: boolean) {
1144 // We set the classes directly here ourselves so that toggling the tooltip state
1145 // isn't bound by change detection. This allows us to hide it even if the
1146 // view ref has been detached from the CD tree.
1147 const tooltip = this._tooltip.nativeElement;
1148 const showClass = this._showAnimation;
1149 const hideClass = this._hideAnimation;
1150 tooltip.classList.remove(isVisible ? hideClass : showClass);
1151 tooltip.classList.add(isVisible ? showClass : hideClass);
1152 if (this._isVisible !== isVisible) {
1153 this._isVisible = isVisible;
1154 this._changeDetectorRef.markForCheck();
1155 }
1156
1157 // It's common for internal apps to disable animations using `* { animation: none !important }`
1158 // which can break the opening sequence. Try to detect such cases and work around them.
1159 if (isVisible && !this._animationsDisabled && typeof getComputedStyle === 'function') {
1160 const styles = getComputedStyle(tooltip);
1161
1162 // Use `getPropertyValue` to avoid issues with property renaming.
1163 if (
1164 styles.getPropertyValue('animation-duration') === '0s' ||
1165 styles.getPropertyValue('animation-name') === 'none'
1166 ) {
1167 this._animationsDisabled = true;
1168 }
1169 }
1170
1171 if (isVisible) {
1172 this._onShow();
1173 }
1174
1175 if (this._animationsDisabled) {
1176 tooltip.classList.add('_mat-animation-noopable');
1177 this._finalizeAnimation(isVisible);
1178 }
1179 }
1180}

Callers 2

showMethod · 0.95
hideMethod · 0.95

Calls 5

_onShowMethod · 0.95
_finalizeAnimationMethod · 0.95
markForCheckMethod · 0.80
removeMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected