* Start the delayed toggle handler if one isn't running already. * * The delayed toggle handler executes the `doToggle` callback after some period of time iff the * users mouse is on an item in the current menu. * * @param doToggle the function called when the user is not moving towar
(doToggle: () => void)
| 182 | * @param doToggle the function called when the user is not moving towards the submenu. |
| 183 | */ |
| 184 | private _startTimeout(doToggle: () => void) { |
| 185 | // If the users mouse is moving towards a submenu we don't want to immediately resolve. |
| 186 | // Wait for some period of time before determining if the previous menu should close in |
| 187 | // cases where the user may have moved towards the submenu but stopped on a sibling menu |
| 188 | // item intentionally. |
| 189 | const timeoutId = setTimeout(() => { |
| 190 | // Resolve if the user is currently moused over some element in the root menu |
| 191 | if (this._pointerTracker!.activeElement && timeoutId === this._timeoutId) { |
| 192 | doToggle(); |
| 193 | } |
| 194 | this._timeoutId = null; |
| 195 | }, CLOSE_DELAY) as any as number; |
| 196 | |
| 197 | this._timeoutId = timeoutId; |
| 198 | } |
| 199 | |
| 200 | /** Whether the user is heading towards the open submenu. */ |
| 201 | private _isMovingToSubmenu() { |