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

Method toggle

src/cdk/menu/menu-aim.ts:153–174  ·  view source on GitHub ↗

* Calls the `doToggle` callback when it is deemed that the user is not moving towards * the submenu. * @param doToggle the function called when the user is not moving towards the submenu.

(doToggle: () => void)

Source from the content-addressed store, hash-verified

151 * @param doToggle the function called when the user is not moving towards the submenu.
152 */
153 toggle(doToggle: () => void) {
154 // If the menu is horizontal the sub-menus open below and there is no risk of premature
155 // closing of any sub-menus therefore we automatically resolve the callback.
156 if (this._menu.orientation === 'horizontal') {
157 doToggle();
158 }
159
160 this._checkConfigured();
161
162 const siblingItemIsWaiting = !!this._timeoutId;
163 const hasPoints = this._points.length > 1;
164
165 if (hasPoints && !siblingItemIsWaiting) {
166 if (this._isMovingToSubmenu()) {
167 this._startTimeout(doToggle);
168 } else {
169 doToggle();
170 }
171 } else if (!siblingItemIsWaiting) {
172 doToggle();
173 }
174 }
175
176 /**
177 * Start the delayed toggle handler if one isn't running already.

Callers

nothing calls this directly

Calls 3

_checkConfiguredMethod · 0.95
_isMovingToSubmenuMethod · 0.95
_startTimeoutMethod · 0.95

Tested by

no test coverage detected